How to make a loop correctly in stages

조회 수: 2 (최근 30일)
Emilia
Emilia 2022년 7월 28일
댓글: Image Analyst 2022년 7월 28일
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

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by