Question: remove some errors

Hello,

How I can remove some problems in my code.

I wrote it before in matlab software, but in some lines, I have some problems with it.

How I can change it in maple to run well?

newmar.mw
 

restart

M := 2; B := 1; C := 3; K := 6; f := 2*exp(-t); q0 := 1; qd0 := -1; qd20 := 1; alpha := 1/2; beta := 1/12; gammaa := 1/4; h := .1; Tf := 2

"N:=size(M,1)  T:=0:h:Tf;  lt:=length(T);  F:=subs(f,t,T);  F:=subs(t=T,f);    qd30:=M\(F(1)-B*qd20-C*qd0-K*q0);   q:=zeros(N,lt)  qd:=zeros(N,lt)  qd2:=zeros(N,lt);  qd3:=zeros(N,lt);  q(:,1):=q0  qd(:,1):=qd0  qd2(:,1):=qd20  qd3(:,1):=qd30"

Error, invalid function arguments

"N:=size(M,1)  T:=0:h:Tf;  lt:=length(T);  F:=subs(f,t,T);  F:=subs(t=T,f);    qd30:=M\(F(1)-B*qd20-C*qd0-K*q0);  q:=zeros(N,lt)  qd:=zeros(N,lt)  qd2:=zeros(N,lt);  qd3:=zeros(N,lt);  q(:,1):=q0  qd(:,1):=qd0  qd2(:,1):=qd20  qd3(:,1):=qd30"

 

"A:=M+alpha*h*B+gammaa*(h^2)*C+beta*(h^3)*K;  for n:=1:lt-1 do      D:=F(n+1)-B*(qd2(:,n)+(1-alpha)*h*qd3(:,n))-...          C*(qd(:,n)+h*qd2(:,n)+(0.5-gammaa)*(h^2)*qd3(:,n))-...          K*(q(:,n)+h*qd(:,n)+(h^2)/2*qd2(:,n)+(1/6-beta)*(h^3)*qd3(:,n));      qd3(:,n+1):=A\D;      qd2(:,n+1):=qd2(:,n)+(1-alpha)*h*qd3(:,n)+alpha*h*qd3(:,n+1);      qd(:,n+1):=qd(:,n)+h*qd2(:,n)+(0.5-gammaa)*(h^2)*qd3(:,n)+gammaa*(h^2)*qd3(:,n+1);      q(:,n+1):=q(:,n)+h*qd(:,n)+(h^2)/2*qd2(:,n)+(1/6-beta)*(h^3)*qd3(:,n)+...          beta*(h^3)*qd3(:,n+1);  end do"

Error, invalid function arguments

"A:=M+alpha*h*B+gammaa*(h^2)*C+beta*(h^3)*K;  for n:=1:lt-1 do      D:=F(n+1)-B*(qd2(:,n)+(1-alpha)*h*qd3(:,n))-...          C*(qd(:,n)+h*qd2(:,n)+(0.5-gammaa)*(h^2)*qd3(:,n))-...          K*(q(:,n)+h*qd(:,n)+(h^2)/2*qd2(:,n)+(1/6-beta)*(h^3)*qd3(:,n));      qd3(:,n+1):=A\D;      qd2(:,n+1):=qd2(:,n)+(1-alpha)*h*qd3(:,n)+alpha*h*qd3(:,n+1);      qd(:,n+1):=qd(:,n)+h*qd2(:,n)+(0.5-gammaa)*(h^2)*qd3(:,n)+gammaa*(h^2)*qd3(:,n+1);      q(:,n+1):=q(:,n)+h*qd(:,n)+(h^2)/2*qd2(:,n)+(1/6-beta)*(h^3)*qd3(:,n)+...          beta*(h^3)*qd3(:,n+1);  end do"

 

plot(T, q, 'r-o', 'linewidth', 1.5)

Error, (in plot) unexpected options: [r-o, linewidth, 1.5]

 

``


 

Download newmar.mw

 

Please Wait...