Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

how to give a name to every case in the loop as the following example ?

조회 수: 1 (최근 30일)
mohammad
mohammad 2014년 6월 14일
마감: MATLAB Answer Bot 2021년 8월 20일
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

답변 (1개)

Azzi Abdelmalek
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
  댓글 수: 4
mohammad
mohammad 2014년 6월 14일
thank you so much my brother
mohammad
mohammad 2014년 6월 19일
편집: mohammad 2014년 6월 19일
how can i call up either part of the results like (e1,e5,e6,e9)or (from e1 to e7)? then i need to combin them in one array

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by