Matlab 根据变量值打印
我需要确定是否存在Matlab 根据变量值打印,matlab,if-statement,Matlab,If Statement,我需要确定是否存在F。如果F存在,则皮带为“V形皮带”,如果不存在,则为“水平皮带” 这是我的密码 F=input if F exist fprint('V belt') else fprint('Horizontal belt') end 基本上,我也不知道我写了什么 只需使用,例如 好的,根据你的评论,我建议: F = []; while isempty(F) F = input('Enter the value of Fa: '); end if F == 0
F
。如果F
存在,则皮带为“V形皮带”,如果不存在,则为“水平皮带”
这是我的密码
F=input
if F exist
fprint('V belt')
else
fprint('Horizontal belt')
end
基本上,我也不知道我写了什么 只需使用,例如
好的,根据你的评论,我建议:
F = [];
while isempty(F)
F = input('Enter the value of Fa: ');
end
if F == 0
% ...
else
% ...
end
这是您编写的实际代码吗?Fa=input('输入Fa:'的值);如果Fa==0 fprint(‘滚珠轴承’)或者fprint(‘滚柱轴承’)endI想到了这一点,但仍然无法执行。需要帮助修改。'Fa=input('输入Fa的值:');如果Fa==0 fprint(“滚珠轴承”)或fprint(“滚柱轴承”)end”,这是因为对于
输入
而言,返回值为空,但在坏的情况下存在。只需使用isempty
即可。
F = [];
while isempty(F)
F = input('Enter the value of Fa: ');
end
if F == 0
% ...
else
% ...
end