Error using * Dimension do not match
Show older comments
this is my code :
function [f,J] = NR(~)
% f1 une fonction continue f1(s,phi) de deux variables.
% f2 une fonction continue f2(s,phi) de deux variables.
% gradf1 chaîne de caractères qui nomme le gradient de la fonction
% f1(x,y) de deux variables.
% gradf2 chaîne vectorielle qui nomme le gradient de la fonction
% f2(x,y) de deux variables.
%
%Définir les variables
r = 3; %[cm] longueur de la manivelle
l = 10;%[cm] longueur du maillon flottant
syms s phi theta;
%définir Fonctions
f1 = r* sin(theta)-l*sin(phi)-((1/3)*cos(s))-((2/3)*(cos(s/44))^2);
f2 = r*cos(theta)-l*cos(phi)-s;
f = [f1,f2];
%Définir jacobian
J = [diff(f1,'s') diff(f1,'phi')
diff(f2,'s') diff(f2,'phi')];
end
%valeurs supposées de s et phi
s = input('valeurs initiales s0 = ');
phi = input('valeurs initiales phi0 = ');
v(1) = s';
v(2) = phi';
%conditions initials
[f, Jac] = NR();
V0 = (gradf1);
maxIter = 72;
tolV = 1e-4;
% Calcul avec Newton Raphson
V = V0;
Vold = V0;
for i = 1:maxIter
theta = 0:5:2*pi;
[f, Jac] = NR();
V = V -inv(Jac)*f;
err(ones(0,i)) = abs(V-Vold);
Vold =V;
if (err(ones(0,i))<tolV)
break;
end
end
sorry the comments are in french, I hope it's not a problem
When I run my coden I have these two errors and I don't know how to solve them.

Accepted Answer
More Answers (0)
Categories
Find more on Mathematics in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
