how can i solve the error in this code?

Hello.
i have try many time to solve this code but it still get error at [t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options). I need someone to check this...
thank you.
%Programs - b - Lorenz system
clear
MaranV=inline('(-1/3)*((13/(300*(8/3)))-9)*x(1)+(1/3)(11+(3/(300*(8/3))))*x(4)+(4/(3*(8/3)));(1/10)*((1/4)*x(1)+(3/4)*x(4)-(13/2)*x(2)-x(1)*x(3)-3*x(4)*x(3));(1/10)*((-45/2)*x(3)+x(1)*x(2)+3*x(4)*x(2));6*((-1/3)*((13/(300*(8/3)))-9)*x(1)+(1/3)*(11+(3/(300*(8/3))))*x(4)+(4/(3*(8/3)))*x(2))-9*x(4)','t','x');
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
[t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
subplot(2,2,1)
plot3(xa(:,1),xa(:,2),xa(:,3),'.','MarkerSize',1)
xlabel ('X')
ylabel ('Y')
zlabel ('Z')
%axis([.7 .9 1.5 1.7 .8 1])
title(['(a) r=300'])
grid on
axis ij
axis square
%set(gcf,'PaperPosition',[2 2 4 4])
%set(gca,'PlotBoxAspectRatio',auto)
%-------------------------------------------------------------
MaranV=inline('[(-1/3)*((13/(360*(8/3)))-9)*x(1)+(1/3)(11+(3/(360*(8/3))))*x(4)+(4/(3*(8/3)));(1/10)*((1/4)*x(1)+(3/4)*x(4)-(13/2)*x(2)-x(1)*x(3)-3*x(4)*x(3));(1/10)*((-45/2)*x(3)+x(1)*x(2)+3*x(4)*x(2));6*((-1/3)*((13/(360*(8/3)))-9)*x(1)+(1/3)*(11+(3/(360*(8/3))))*x(4)+(4/(3*(8/3)))*x(2))-9*x(4)]','t','x');
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
[t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
subplot(2,2,2)
%figure(1)
plot3(xa(:,1),xa(:,2),xa(:,3),'.','MarkerSize',1)
xlabel ('X')
ylabel ('Y')
zlabel ('Z')
%axis([.7 .9 1.5 1.7 .8 1])
title(['(b) r=360'])
grid on
axis ij
axis square
%set(gcf,'PaperPosition',[2 2 4 4])
%set(gca,'PlotBoxAspectRatio',auto)
%----------------------------------------------------------------
MaranV=inline('(-1/3)*((13/(400*(8/3)))-9)*x(1)+(1/3)(11+(3/(400*(8/3))))*x(4)+(4/(3*(8/3)));(1/10)*((1/4)*x(1)+(3/4)*x(4)-(13/2)*x(2)-x(1)*x(3)-3*x(4)*x(3));(1/10)*((-45/2)*x(3)+x(1)*x(2)+3*x(4)*x(2));6*((-1/3)*((13/(400*(8/3)))-9)*x(1)+(1/3)*(11+(3/(400*(8/3))))*x(4)+(4/(3*(8/3)))*x(2))-9*x(4)','t','x');
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
[t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
subplot(2,2,3)
%figure(1)
plot3(xa(:,1),xa(:,2),xa(:,3),'.','MarkerSize',1)
xlabel ('X')
ylabel ('Y')
zlabel ('Z')
%axis([.7 .9 1.5 1.7 .8 1])
title(['(c) r=400'])
grid on
axis ij
axis square
%set(gcf,'PaperPosition',[2 2 4 4])
%set(gca,'PlotBoxAspectRatio',auto)
%-----------------------------------------------------
MaranV=inline('(-1/3)*((13/(500*(8/3)))-9)*x(1)+(1/3)(11+(3/(500*(8/3))))*x(4)+(4/(3*(8/3)));(1/10)*((1/4)*x(1)+(3/4)*x(4)-(13/2)*x(2)-x(1)*x(3)-3*x(4)*x(3));(1/10)*((-45/2)*x(3)+x(1)*x(2)+3*x(4)*x(2));6*((-1/3)*((13/(500*(8/3)))-9)*x(1)+(1/3)*(11+(3/(500*(8/3))))*x(4)+(4/(3*(8/3)))*x(2))-9*x(4)','t','x');
options = odeset('RelTol',1e-4,'AbsTol',1e-4);
[t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
subplot(2,2,4)
%figure(1)
plot3(xa(:,1),xa(:,2),xa(:,3),'.','MarkerSize',1)
xlabel ('X')
ylabel ('Y')
zlabel ('Z')
%axis([.7 .9 1.5 1.7 .8 1])
title(['(d) r=500'])
grid on
axis ij
axis square
%set(gcf,'PaperPosition',[2 2 4 4])
%set(gca,'PlotBoxAspectRatio',auto)
hold off

5 Comments

I would recommend you to:
1. Format your code.
2. Don't tag individuals, as it discourages others from answering your question.
And please post the error message. It is hard to debug, when the error is unknown.
To Robert P. 1. Format means that I should change all the code according to the latest version. it is like that? 2. I am sorry for that. Thank you for your responns. Smile.
To Jan Simon, this is the error that appeared after i corrected multiplication character in "(1/3)(11+"
Error in ==> inline.feval at 36 INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> odearguments at 110 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> MarVar at 5 [t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
Thank for your respons. Smile
Are you sure, that this is the complete message? We see, where the problem occurres, but no hint about the nature of the problem. This is very unusual for Matlab.

Sign in to comment.

 Accepted Answer

You are missing a multiplication character in "(1/3)(11+"

1 Comment

But it still appear this error. what's means? i am not very understand about this error.
Error in ==> inline.feval at 36 INLINE_OUT_ = inlineeval(INLINE_INPUTS_, INLINE_OBJ_.inputExpr, INLINE_OBJ_.expr);
Error in ==> odearguments at 110 f0 = feval(ode,t0,y0,args{:}); % ODE15I sets args{1} to yp0.
Error in ==> ode45 at 173 [neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, odeFcn, ...
Error in ==> MarVar at 5 [t,xa]=ode45(MaranV,[0 210],[0.9,0.9,0.9,0.9],options);
Thank for your respons. Smile

Sign in to comment.

More Answers (1)

Jan
Jan on 22 May 2013
Using inline objects have the strong disadvantage, that it is impossible to use the debugger to find bugs. Therefore I suggest to avoid them and write such large formulas to M-functions instead, where the debugger and the MLint code checker can reveal problems much easier.
Expresions like "(-1/3)*((13/(500*(8/3)))-9)" are extremely ugly. On one hand I have to waste time with counting, if the trailing parenthesis belongs to the leading one or not. And on the other hand calculating such expressions in each function evaluation wastes a lot of time. Performing this once and using a single numerical value directly would be nicer, faster and less confusing, when you have to debug the code.

Categories

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!