Filter löschen
Filter löschen

error when use maple formula in matlab

1 Ansicht (letzte 30 Tage)
ebi
ebi am 20 Okt. 2013
Kommentiert: Walter Roberson am 22 Okt. 2013
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 Kommentare
Walter Roberson
Walter Roberson am 20 Okt. 2013
When the problem occurs, which line of your code is being executed ?
ebi
ebi am 20 Okt. 2013
first error is in line of :
maple('assign','F1',F1);
or
maple('assign','t1',t1);

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
Walter Roberson am 20 Okt. 2013
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 Kommentare
Walter Roberson
Walter Roberson am 20 Okt. 2013
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
ebi am 20 Okt. 2013
i try it but not work have error .my input and output are :
define L (lenght of wagon -m) : 24.5
define V (speed of train -km/h) : 270
define X1(distance betwean 2 wagon -m) : 0.6
define X2(distance betwean 2 middle wheels -m): 20
define X (distance betwean 2 near wheels -m) : 1.5
define W (total weight of wagon and passenger -ton) : 100
Please wait 5 seconds only!
Press any key to see All input.
*** V : (speed of train)= 75 m/s
*** L : (lenght of wagon) = 24.5 m
*** X1: (distance betwean 2 wagon) = 0.6 m
*** X2: (distance betwean 2 middle wheels) = 20 m
*** X : (distance betwean 2 near wheels) = 1.5 m
*** W : (total weight of wagon) = 100 ton
*** F1: (force of 1 wheel) = 122.625 kN
*** F1 = 122.625 kN
* t1 = 0.02 s
* t2 = 0.28667 s
* t3 = 0.30667 s
* t4 = 0.33467 s
*|Error using maple (line 178)
Error using maplemex
Error, invalid left hand side in assignment
Error in maple_function (line 33)
maple('assign','F1',F1);|*
--------------------------------------
program is :
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(f, t = 0 .. t4)'); %coefficient of fourier series
maple('an=2/T.int(f.sin(2.n.Pi.t/T)), t = 0 .. t4)'); %coefficient of fourier series
maple('bn=2/T.int(f.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)')

Melden Sie sich an, um zu kommentieren.


ebi
ebi am 22 Okt. 2013
is there any body help me ? is there any body want to answer my question ?
  3 Kommentare
Walter Roberson
Walter Roberson am 22 Okt. 2013
Modern student versions would be more likely to use MuPAD than Maple.
Walter Roberson
Walter Roberson am 22 Okt. 2013
I want to answer the question, but I do not have the appropriate toolboxes.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by