matrix computations in the loop as cell.

조회 수: 7 (최근 30일)
sermet
sermet 2014년 5월 20일
답변: Roger Wohlwend 2014년 5월 21일
coord=[10 12;15 17;20 20;32 32;50 52;44 45;65 69];
v=[1 1.01 1.02;1.01 1.03 1.03;1.11 1.11 1.12;1 1.14 1.12 ;1 1 1;1 1 1;1 1 1];
birim=[1];
count=[3;4];
for k=1:2
if k == 1
row1 = 1;
else
row1 = 1 + sum(count(1:k-1));
end
row2 = sum(count(1:k));
AA{k} =coord(row1:row2, :)
br{k}=repmat(birim,count(k),1)
Lx{k}=v(row1:row2,1)
Ly{k}=v(row1:row2,2)
Lz{k}=v(row1:row2,3)
end
%in here, I wanna compute this algorithm inside the loop;
%for example for k=1;
AA_1=[1 10 12;1 15 17;1 20 20] %br+AA
Lx_1=[1;1.01;1.11]
Ly_1=[1.01;1.03;1.11]
Lz_1=[1.02;1.03;1.12]
x_x1=AA_1*Lx_1 %result1
x_y1=AA_1*Ly_1 %result2
x_z1=AA_1*Lz_1 %result3
%firstly, I cannot merge AA and br matrixes as it look above then I cannot extract them from cell to double in the loop for computations(x_x1,x_y1,x-z1).

채택된 답변

Roger Wohlwend
Roger Wohlwend 2014년 5월 21일
In the loop you define AA and br as cell arrays. So, if you want to merge them, use [br{1},AA{1}] and [br{2},AA{2}];

추가 답변 (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