Untitled
unknown
matlab
a year ago
1.0 kB
11
Indexable
RelTol=1.e-06; AbsTol=1.e-09; % Write Newton's method using every grid point as the initial condition % Perform enough iterations that every initial condition converges to a root % Save the x-values of the converged roots in the matrix X % To pass the assessment, every pixel in the figure must be correctly colored %!!!!!!!!! Set initial value y=3*sqrt(2) for all values (x,z) on the grid !!!!!!!!!! % It's ok to change the for loop of j and i for j = 1:nz for i = 1:nx % setting the x y z value x = X(j, i); y = 3*sqrt(2); z = Z(j, i); error=Inf; while error > max(RelTol*max(abs([x,y,z])),AbsTol) J= [-sigma sigma 0 ; r-z -1 -x; y x -beta]; % DEFINE THE JACOBIAN MATRIX rhs = -[sigma*(y-x); r*x-y-x*z; x*y-beta*z]; % DEFINE THE RIGHT-HAND SIDE delta_xyz=J\rhs; x = x + delta_xyz(1); y = y + delta_xyz(2); z = z + delta_xyz(3); error = max(abs(delta_xyz)); end X(j, i) = x; Z(j, i) = z; end end
Editor is loading...