Info
此问题已关闭。 请重新打开它进行编辑或回答。
how to give a name to every case in the loop as the following example ?
1 次查看(过去 30 天)
显示 更早的评论
i have a loop which looks like
clc
clear
a=[1:10];
for k=1:10;
b=nchoosek(a,k)
end
but, i want to give a name to every case in the loop in order to be as well: b1=.... b2=.... b3=.... . . . b10=.... until i can call up any one of them separately. i have tried to use this code '(eval(sprintf('b%d = [1:i]',i))' but it ended in failure . please , help me thank you
0 个评论
回答(1 个)
Azzi Abdelmalek
2014-6-14
编辑:Azzi Abdelmalek
2014-6-14
a=[1:10];
for k=1:10;
b{k}=nchoosek(a,k)
end
It's not good to create several variables, just use a cell class, or or a struct class
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!