フィルターのクリア

error at for loop end (courseera course ref. solution- fixed points Lorentz equations)

4 ビュー (過去 30 日間)
Sara Ismail-Sutton
Sara Ismail-Sutton 2021 年 4 月 13 日
編集済み: Cris LaPierre 2021 年 4 月 13 日
r=28; sigma=10; b=8/3;
RelTol=1.e-06; AbsTol=1.e-09;
for nroot=1:3
if nroot==1, x=1; y=1; z=1; end
if nroot==2, x=10; y=10; z=10; end
if nroot==3, x=-10; y=-10; z=-10; end
error=Inf;
while error > max(RelTol*max(abs([x,y,z])),AbsTol)
J=[-sigma, sigma, 0; r-z, -1, -x; y, x, -beta;];
rhs = -[sigma*(y-x); r*x-y-x*z; x*y-beta*z];
delta_xyz=rhs/J;
x = x + delta_xyz(1);
y = y + delta_xyz(2);
z = z + delta_xyz(3);
error=max(abs(delta_xyz));
end
xroot(nroot)=x; yroot(nroot)=y; zroot(nroot)=z;
end
roots=[xroot;yroot;zroot];
fprintf('steady-state solution:\n')
fprintf('(x, y, z) = (%2.0f,%2.0f,%2.0f) \n', roots(:,1));
fprintf('(x, y, z) = (%7.5f,%7.5f,%3.0f) \n', roots(:,2));
fprintf('(x, y, z) = (%7.5f,%7.5f,%3.0f) \n', roots(:,3));
They give the reference solution code as above. When I try to run it I get the error message, which I am really confused with cause this line is just 'end' of for for loop I thought.
"Error in beta (line 19)
y = exp(betaln(z,w));"
many thanks,

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 4 月 13 日
編集済み: Cris LaPierre 2021 年 4 月 13 日
I wonder if the variable b defined in the first line is supposed to be beta.
However, changing that just led to a new error. If this is truly the reference solution, you should notify the course instructor.

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by