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!