use of eval in loop, Index exceeds matrix dimensions.
Show older comments
Hi,
I have 250 decision trees in a dataset called c1 .. c250
I am trying to use the isbranch function in a loop.
This is the code:
for i = 1:250
STR = sprintf('isbranch(c%d)',i);
branches = eval(STR);
end;
I used eval before to use these trees, and no error was showing then. Now I keep getting the error:
Index exceeds matrix dimensions.
Any suggestions would be welcome.
Thanks,
Michiel
4 Comments
Oleg Komarov
on 6 Jun 2012
One reason to avoid eval(). Use dynamic field indexing of structures.
Walter Roberson
on 6 Jun 2012
http://matlab.wikia.com/wiki/FAQ#How_can_I_create_variables_A1.2C_A2.2C....2CA10_in_a_loop.3F
per isakson
on 6 Jun 2012
Are "c1 .. c250" objects of the class, classregtree?
per isakson
on 7 Jun 2012
How does the full error message read?
Answers (0)
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!