I need to pass different values of (theta_r) into F(1) and F(2) to get different values of x(1) and x(2).
i use this code, but it shows me many errors.
clear all;
%defining the parameters.
global R L3 L4 L5 theta_r
R=80; L5=360; L4=360; L3=120; n=2; m=100*n;
theta_r=linspace(0,2*pi*n,m);
function F = value(x,theta_r)
F(1)=R*sin(theta_r)+L3*sin(x(1))-L5*sin(x(2));
F(2)= R*cos(theta_r)+L3*cos(x(1))-L5*cos(x(2))-L4;
end
for b = 1:numl(theta_r)
x(b,:)=fsolve(@(x)value(x,theta_r(b),[1,0]));
end

 Respuesta aceptada

Jan
Jan el 20 de Mayo de 2021
Editada: Jan el 21 de Mayo de 2021

0 votos

global R L3 L4 L5
R=80; L5=360; L4=360; L3=120; n=2; m=100*n;
theta_r=linspace(0,2*pi*n,m);
for b = 1:numel(theta_r) % fixed: "numl"
x(b,:) = fsolve(@(x) value(x, theta_r(b)), [1,0]);
end
function F = value(x,theta_r)
global R L3 L4 L5
F(1)=R*sin(theta_r)+L3*sin(x(1))-L5*sin(x(2));
F(2)= R*cos(theta_r)+L3*cos(x(1))-L5*cos(x(2))-L4;
end

5 comentarios

Luqman Alabri
Luqman Alabri el 20 de Mayo de 2021
Thank you so much.
Luqman Alabri
Luqman Alabri el 21 de Mayo de 2021
Hello Jan,
How to make sure that the angles x(1) and x(2) were mesured from the positive x axis, because when I plot input versus output there were some incorrect values of x(1) and x(2).
like this:
Torsten
Torsten el 21 de Mayo de 2021
You could try
initial = [1,0];
for b=1:numel(theta_r)
x(b,:) = fsolve(@(x) value(x,theta_r(b),initial);
initial = x(b,:);
end
Jan
Jan el 21 de Mayo de 2021
@Torsten: A good idea.
Luqman Alabri
Luqman Alabri el 21 de Mayo de 2021
Thank you all.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 20 de Mayo de 2021

Comentada:

el 21 de Mayo de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by