Filter löschen
Filter löschen

How to make a loop correctly in stages

1 Ansicht (letzte 30 Tage)
Emilia
Emilia am 28 Jul. 2022
Kommentiert: Image Analyst am 28 Jul. 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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by