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
John Doe
2013년 5월 21일
I would recommend you to:
1. Format your code.
2. Don't tag individuals, as it discourages others from answering your question.
Jan
2013년 5월 21일
And please post the error message. It is hard to debug, when the error is unknown.
che ku norsyazwani
2013년 5월 22일
편집: che ku norsyazwani
2013년 5월 22일
che ku norsyazwani
2013년 5월 22일
Jan
2013년 5월 22일
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.
채택된 답변
추가 답변 (1개)
Jan
2013년 5월 22일
0 개 추천
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.
카테고리
도움말 센터 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!