tisdag, november 17, 2009

INTE kompis med MatLab

INTE kompis med MATLAB!!!!!!

clear all
Y=-3:0.01:3;
Z=0.01:0.01:2;
[y,z]=meshgrid(Y,Z);
Q=(sin((z.^3-2.^y)./3)+y.^2+log(z)-3).^2+(((z.^3-2.^y).^2./9)+y.^2+z.^3-6).^2;
index=find(Q>1);
Q(index)=inf;surfc(y,z,Q);
rotate3d on;
grid on

x=[2.05 0.855]';
korr=[1 1]';
antal=0;
langd=1;
while langd>1e-5 && antal<100
f=[sin((x(2).^3-2.^x(1))./3)+x(1).^2+log(x(2));((x(2).^3-2.^x(1)).^2)./9+x
(1).^2+x (2).^3-6];
jac=[cos(x(2).^3-2.^x(1)).*(-log(2).*2.^x(1)./3)+2.*x(1) (cos((x(2).^3-2.^x(1))./3))
.*(x(2).^2)+1./x(2);(-2)./9.*log(2).*2.^x(1).*(x(2).^3-2.^x(1))+2.*x(1) (2./3).*
x(2).^2*(x(2).^3-2.*x(1))+3.*x(2).^2];
korr=jac\f;
X=x;
x=x-korr;
antal=antal+1;
langd=orm(korr,inf);
end

X, antal

This sucks!!!

Inga kommentarer: