Demo entry 6362362

holaaa

   

Submitted by anonymous on May 08, 2017 at 19:02
Language: Matlab. Code size: 625 Bytes.

clc
clear all
close all

%Aplicación del Método de Newton-Raphson

q1=1;
q2=pi/9;
q=[q1;q2];

%Matriz de coeficientes del sistema de ecuaciones no lineal

C=[cos(q(2,1))+q(1,1).*sin(q(2,1))-2; sin(q(2,1))+q(1,1).*cos(q(2,1))-(3/2)];

%Jacobiano de la matriz C

J=[sin(q(2,1)),q(1,1)*cos(q(2,1))-sin(q(2,1));cos(q(2,1)),cos(q(2,1))-q(1,1)*sin(q(2,1))];

%Bucle con semilla de 0.01

while norm(C)>=0.01
    
C=[cos(q(2,1))+q(1,1).*sin(q(2,1))-2; sin(q(2,1))+q(1,1).*cos(q(2,1))-(3/2)];

J=[sin(q(2,1)),q(1,1)*cos(q(2,1))-sin(q(2,1));cos(q(2,1)),cos(q(2,1))-q(1,1)*sin(q(2,1))];

q=q-inv(J)*C;

end

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).