# I have a loop command in Maple, do you know how to write it in Matlab?

3 views (last 30 days)
Mehdi on 15 Sep 2022
Answered: Walter Roberson on 15 Sep 2022
I have a loop command in Maple, do you know how to write it in Matlab?
for k to 11 do
X[k+1] := eval(V-G1 . EQ, Equate(V, X[k])) :
end do
t=1;
syms p__1 tau__1 tau__2 tau__3
V = [tau__1; tau__2 ;tau__3; p__1]
V =
EQ =[(1519010779748915*p__1)/9671406556917033397649408 + (37082872076992779027*tau__1)/4611686018427387904 - (10269089160577095*tau__2)/2361183241434822606848 - (2560198925000835947*tau__3)/37778931862957161709568 + 0.02632670329369235494973966905587*sin(25*t);
(4636910109289096185*tau__2)/576460752303423488 - (10269089160577095*tau__1)/2361183241434822606848 - (3843333523122587*p__1)/2417851639229258349412352 + (65247335564564535*tau__3)/4722366482869645213696 - 0.023998204867523233580749613411132*sin(25*t);
(65247335564564535*tau__2)/4722366482869645213696 - (2560198925000835947*tau__1)/37778931862957161709568 - (8969816766329343*p__1)/1208925819614629174706176 + (580819293998174151*tau__3)/72057594037927936 + 0.023995357692118428094048561849008*sin(25*t);
(6650483120930606653*p__1)/11258999068426240 + (1519010779748915*tau__1)/9671406556917033397649408 - (3843333523122587*tau__2)/2417851639229258349412352 - (8969816766329343*tau__3)/1208925819614629174706176]
EQ =
G = jacobian(EQ,V);
G1 = inv(G);
X=[zeros(4,1)];
X=sym(X);
X(1:4 , 1)=[-0.0032740549266896589425167620590331*sin(25*t);
0.0029834606253022400734802395833198*sin(25*t);
-0.0029769443257114050228215642498688*sin(25*t);
-0.000000000000028494667434775680457822160620761*sin(25*t)]
X =

Walter Roberson on 15 Sep 2022
syms V
for k = 1 : 11
X(k+1) = subs(V - G1 * EQ, V, X(k));
end

### Categories

Find more on Code Performance in Help Center and File Exchange

R2021b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!