How to make a loop correctly in stages

2 views (last 30 days)
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

Accepted Answer

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

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!