How can I get the first row of different matrices into one matrix?

조회 수: 1 (최근 30일)
Cody Cambre
Cody Cambre 2019년 10월 23일
댓글: Cody Cambre 2019년 10월 23일
I have a for loop stating an interval and another for loop inside that runs a backslash through intervals. The backslash produces 7 (5x1) matricies. I need to get each row into a matrix that is (7x1). Below are the first three matricies my code produced.
6.8000 (r3)
8.4500
-0.0000
6.2832
6.2832
6.1167(r3)
8.7892
-2.4183
6.5619
6.5619
4.3646(r3)
9.2953
-3.8731
6.7130
6.7130

답변 (1개)

Walter Roberson
Walter Roberson 2019년 10월 23일
for iteration = 1 : 7
this_result = something \ something_else;
combined_results(iteration,:) = this_result(1,:);
end
  댓글 수: 1
Cody Cambre
Cody Cambre 2019년 10월 23일
clear,clc
r1= 4.8;
r2= 2;
r3= 5.6011;
r4= 9.0129;
r5= 3.1352;
r6= 3.65;
t1= -pi;
t2=[0:2*pi];
t3= 5.59279;
t4= 5.59279;
t5= -pi/2;
t6= 0;
x=[ r3; r4; r5; t3; t4];
for t2=[0:2*pi];
for i=1:6
f1= r2.*cos(t2)-r3.*cos(t3)-r1.*cos(t1);
f2= r2.*sin(t2)-r3.*sin(t3)-r1.*sin(t1);
f3= r6.*cos(t6)+r5.*cos(t5)-r4.*cos(t4)-r1.*cos(t1);
f4= r6.*sin(t6)+r5.*sin(t5)-r4.*sin(t4)-r1.*sin(t1);
f5= t4-t3;
f=[f1; f2; f3; f4; f5];
A=[-cos(t3) 0 0 r3.*sin(t3) 0;
-sin(t3) 0 0 -r3.*cos(t3) 0;
0 -cos(t4) 0 0 r4.*sin(t4);
0 -sin(t4) -1 0 -r4.*cos(t4);
0 0 0 -1 1];
x= x-A\f;
r3= x(1,1);
r4= x(2,1);
r5= x(3,1);
t3= x(4,1);
t4= x(5,1);
end
end
Heres the full code. When I put your for loop in it produced a matrix of the first answers only

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

카테고리

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