Borrar filtros
Borrar filtros

How to make a loop correctly in stages

1 visualización (últimos 30 días)
Emilia
Emilia el 28 de Jul. de 2022
Comentada: Image Analyst el 28 de Jul. de 2022
Hello,
I'm trying to place these numerical values in the steps of a loop and it didn't turn out well, the software doesn't pick it up. Thanks for the helpers
alpha=120;
theta=90;
R=40;
S1=20;
S2=15;
r=(R/sqrt(2));
X_e=S1+r*sqrt(2)*sind(alpha)+r*sqrt(2)*sind(alpha+theta); %Direct kinematics formula in the x axis
Y_e=S2+r*sqrt(2)*cosd(alpha)+r*sqrt(2)*cosd(alpha+theta); %Direct kinematics formula in the y axis
phi_e=alpha+theta; %Direct kinematics formula in the angle axis
if alpha>160 && theta>110 && R>50 && S1>30 && S2>40
error('One of the entered numbers is not within range, please re-type normal numeric values.') %Error message
else
eqn = sind(alpha)*sind(alpha+theta)+sind(alpha+theta)*sind(alpha+theta)+cosd(alpha)*cosd(alpha+theta)+cosd(alpha+theta)*cosd(alpha+theta);
if eqn==0
sprintf('In this determinant matrix equation with the %d and %f values there are no singular states.',alpha,theta);
else
sprintf('In this determinant matrix equation with the values %d and %f there are singular states .',alpha,theta);
end
end

Respuesta aceptada

Walter Roberson
Walter Roberson el 28 de Jul. de 2022
Use fprintf instead of sprintf
  4 comentarios
Emilia
Emilia el 28 de Jul. de 2022
It works well, Thank you! :)
Image Analyst
Image Analyst el 28 de Jul. de 2022
@Emilia Then please click the "Accept this answer" link to award @Walter Roberson "reputation points". Thanks in advance. 🙂

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by