How can we store many matrices(z) from for loop in a single matrix D(say) in my problem.
조회 수: 1 (최근 30일)
이전 댓글 표시
x=[1 2 3];
y=1./x;
for l=1:3;
I=eye(3,3);
z=y(l)*I;
end
댓글 수: 0
답변 (1개)
Prasad Reddy
2020년 5월 17일
% If you want your matrices z1,z2,z3 to be stored in side by side ie D=[z1 z2 z3] the following code helps
clc
clear all
x=[1 2 3];
y=1./x;
D=[];
for l=1:3;
I=eye(3,3);
z=y(l)*I;
D=[D,z]
end
% If you want your matrices z1,z2,z3 to be stored in a column manner ie D=[z1
% z2
% z3]
%the following code helps
clc
clear all
x=[1 2 3];
y=1./x;
D=[];
for l=1:3;
I=eye(3,3);
z=y(l)*I;
D=[D;z]
end
% Please give a up thumb if this answer works for you. Thank you.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!