Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Matlab eval Function error

  1. Aug 12, 2010 #1
    Dear Friends/Experts,

    I have below code for execution but got error. Any anyone pin point and correct me please?

    function H = autclus

    for i = 1:500
    V = eval(['G' int2str(i)]);
    end

    end


    ??? Error using ==> eval
    Undefined function or variable 'G1'.

    Error in ==> autclus at 10
    V = eval(['G' int2str(i)]);
     
  2. jcsd
  3. Aug 12, 2010 #2
    Why can't you use like this

    for i=1:500

    v{i}=strcat('G',int2str(i));

    end
     
  4. Aug 12, 2010 #3
    Hi,

    Thank you very much for the reply.
    If it's using array, I have a little problem here as i will subsequently use this function.

    H = dendrogram(Z, 'labels', V);

    maybe this is the reason i attempted for eval. any alternative? mate.. :)
    Im still a rookie in matlab
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook