how can i solve the error in this code?
2 views (last 30 days)
Show older comments
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
Jan
on 22 May 2013
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.
Accepted Answer
More Answers (1)
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.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!