How can you use the Matlab eval function in this scenario?

  • Context: MATLAB 
  • Thread starter Thread starter mashiling
  • Start date Start date
  • Tags Tags
    Error Function Matlab
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 7K views
mashiling
Messages
2
Reaction score
0
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)]);
 
Physics news on Phys.org
Why can't you use like this

for i=1:500

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

end
 
n.karthick said:
Why can't you use like this

for i=1:500

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

end

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