필터 지우기
필터 지우기

create new array with for

조회 수: 2 (최근 30일)
Josefina Ottitsch
Josefina Ottitsch 2019년 3월 5일
댓글: madhan ravi 2019년 3월 5일
Hello,
I have a code similar to the following:
for z=1:5
'A''num2str(z)'=[1;3*z]
end
I would like my program to create a new array A'z' (ex:A1=[1;3*1],...A5=[1;3*5]) for every for loop, I do not want to have an added row to my array, I really want to create a new array.
How do I do this?
Thank you for the support!
  댓글 수: 1
madhan ravi
madhan ravi 2019년 3월 5일
why do you need to use a loop?

댓글을 달려면 로그인하십시오.

채택된 답변

KSSV
KSSV 2019년 3월 5일
A = zeros(2,5) ;
for z=1:5
A(:,z) = [1;3*z] ;
end
A(:,1) % this is A1
A(:,3) % this is A3
It is useless to geenrate A1,A2....etc.......you need not to do that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by