I want to save matrix at each iteration to later use for Multiplication
조회 수: 1 (최근 30일)
이전 댓글 표시
I have written a code, it is working fne, but i couldnot save the result at each step.
clear all;
clc
a=0:1;
b=0:1;
c=0:1;
l=length (a);
m=length (b);
n=length (c);
for i=1:l
for j=1:m
for k=1:n
F = [1 a(:,i) b(:,j);0 1 c(:,k);0 0 1]
end
end
end
Please guide me, Thanks
댓글 수: 1
KSSV
2018년 11월 14일
What is that you are trying to do? Looks like, you may do this even without loop? YOu want F to be a matrix of 3*3 or you want to save every row of F?
채택된 답변
Mark Sherstan
2018년 11월 14일
Store it as a cell array (use curly brackets). The following works:
clear all;
clc
a=0:1;
b=0:1;
c=0:1;
l=length (a);
m=length (b);
n=length (c);
counter = 1;
for i=1:l
for j=1:m
for k=1:n
F{counter} = [1 a(:,i) b(:,j);0 1 c(:,k);0 0 1]
counter = counter + 1;
end
end
end
If you wanted to access the first matrix you would call the following:
F{1}
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Environment and Clutter에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!