Iterate through alphabetical names
1 次查看(过去 30 天)
显示 更早的评论
Hello there,
maybe it's a dumb question, but how do I iterate through alphabetical names? Assuming I have matrices A to D, then how can I use those names in a loop?
My approach would be to create a string
names='ABCD'
and loop through those in a loop
for i=0:4
names(i)
end for
But how can I use this for example for the following operation?
boxplot(A(:))
If I simply use
names='ABCD';
for i=0:4
boxplot(name(i)(:))
end for
Then it doesn't work, of course. strcat does not do the job either.
I hope someone has an idea :)
Cheers
0 个评论
采纳的回答
Star Strider
2014-5-22
Not dumb at all.
A = rand(2,10);
B = rand(3,10);
C = rand(4,10);
D = rand(5,10);
names = 'ABCD';
for k1 = 1:length(names)
figure(k1)
boxplot(eval(names(k1)))
end
0 个评论
更多回答(2 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!