save matrixs in different names
이전 댓글 표시
Good morning\evening
I have written this code that gave me 30 [1*30] matrix
I try to save each matrix [1*30] in different names so I can later combine them in one matrix[30*30] using [mat1;mat;...;]
I tried it using for loop in different ways but i have errors
Can you help me =)?!
**********************************
function C=OneCamera(x,y)
LCamera = 5;
WCamera = 6;
LArea = 5;
WArea = 6;
for x=1:LCamera
for y=1:WCamera
for i=1:LArea
for j=1:WArea
d=(i-x)^2+(j-y)^2;
if d<16
C(i,j)=1;
else
C(i,j)=0;
end;
end;
end
x
y
C
A= reshape (C',1,30)
end
end
end
댓글 수: 3
Fangjun Jiang
2011년 10월 9일
use {}Code format next time.
Fangjun Jiang
2011년 10월 9일
Don't name your matrix mat1, mat2, mat3,... In your case, you define your matrix as 30x30 and each time you can set the value for each row. See this post http://www.mathworks.com/matlabcentral/answers/143-how-do-i-make-a-series-of-variables-a1-a2-a3-a10
Walter Roberson
2011년 10월 9일
Duplicate is at http://www.mathworks.com/matlabcentral/answers/17790-combine-30-1-30-matrix-to-one-matrix-30-30
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!