error when use maple formula in matlab
3 次查看(过去 30 天)
显示 更早的评论
in maple i can define formula very simple and we can use maple formula in matlab in some way, in my program it not work and has error. please check it .
clc
clear
L=input(' define L (lenght of wagon -m) : ');
V=input(' define V (speed of train -km/h) : ');
X1=input(' define X1(distance betwean 2 wagon -m) : ');
X2=input(' define X2(distance betwean 2 middle wheels -m): ');
X=input(' define X (distance betwean 2 near wheels -m) : ');
W=input(' define W (total weight of wagon and passenger -ton) : ');
disp( ' ' )
disp('Please wait 5 seconds only!');pause(1);
disp('Press any key to see All input.'); pause;
disp( ' ' )
V=V*1000/3600;disp([' *** V : (speed of train)= ',num2str(V),' m/s'])
disp([' *** L : (lenght of wagon) = ',num2str(L),' m'])
disp([' *** X1: (distance betwean 2 wagon) = ',num2str(X1),' m'])
disp([' *** X2: (distance betwean 2 middle wheels) = ',num2str(X2),' m'])
disp([' *** X : (distance betwean 2 near wheels) = ',num2str(X),' m'])
disp([' *** W : (total weight of wagon) = ',num2str(W),' ton'])
F1=W*9.81/8;
disp([' *** F1: (force of 1 wheel) = ',num2str(F1),' kN'])
%---------------------------------------------------------
t1=X/V;t2=(X+X2)/V;t3=(2*X+X2)/V;t4=(2*X+X2+(L-X2-2*X)+X1)/V;
disp([' *** F1 = ',num2str(F1),' kN'])
disp([' * t1 = ',num2str(t1),' s'])
disp([' * t2 = ',num2str(t2),' s'])
disp([' * t3 = ',num2str(t3),' s'])
disp([' * t4 = ',num2str(t4),' s'])
t1 =0.0001*round(10000*t1);
t2 =0.0001*round(10000*t2);
t3 =0.0001*round(10000*t3);
t4 =0.0001*round(10000*t4);
F1 =0.0001*round(10000*F1);
maple('assign','F1',F1);
maple('assign','t1',t1);
maple('assign','t2',t2);
maple('assign','t3',t3);
maple('assign','t4',t4);
T=t4;
maple('assign','T',T);
syms t
maple('f:= piecewise(0 <= t and t <= t1, F1, t1 < t and t < t2, 0, t2 <=t and t <= t3, F1, t3 < t and t < t4, 0)');
maple('plot(f,t=0..t4)')
T=t4;
maple('a0=1/T.int(g, t = 0 .. t4)'); %coefficient of fourier series
maple('an=2/T*int(g.sin(2.n.Pi.t/T), t = 0 .. t4)'); %coefficient of fourier series
maple('bn=2/T*int(g.cos(2.n.Pi.t/T), t = 0 .. t4)'); %coefficient of fourier series
maple('plot(an,t=0..t4)')
maple('plot(bn,t=0..t4)')
maple('ft=a0+sum(an.cos(2.n.Pi.t/T)+bn.cos(2.n.Pi.t/T)), n = 1 .. 200)'); %fourier series
maple('plot(ft,t=0..t4)')
--------------------- error is
Error using maple (line 178)
Error using maplemex
Error, invalid left hand side in assignment
2 个评论
回答(2 个)
Walter Roberson
2013-10-20
Your line
maple('f:= piecewise(0 <= t and t <= t1, F1, t1 < t and t < t2, 0, t2 <=t and t <= t3, F1, t3 < t and t < t4, 0)');
correctly assigns a value to "f". But your lines starting from
maple('a0=1/T.int(g, t = 0 .. t4)');
define equations rather than do assignments.
The maple operator "=" is equation; the maple operator ":=" is assignment.
3 个评论
Walter Roberson
2013-10-20
As an experiment, try using
maple('assign', 'myF1', F1);
If that works then the guess would be that F1 exists and is protected in Maple.
ebi
2013-10-22
3 个评论
Walter Roberson
2013-10-22
I want to answer the question, but I do not have the appropriate toolboxes.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!