【发布时间】:2021-09-03 15:09:30
【问题描述】:
我是第一次尝试if 测试,实际上函数也是如此。
这是脚本:
function trial()
I = input("f INPUT > Manually input frequency value? (yes/no):");
if I = "yes";
f = input("Please input the frequency value : \n")
elseif I = "no";
f = randi([100 1000],5,5)
endif
O = 2*pi*f;
fprintf("%.2f \n",O);
plot(f,O);
xlabel("Frequency");
ylabel("Angular Frequency");
end
f INPUT > Manually input frequency value? (yes/no):"no"
Please input the frequency value :
有两件事我不明白:
- 为什么我必须用引号写条件? (即
"yes"不是yes或"no"不是no)。 - 为什么
'no'条件在应该是randi时运行输入命令?
谁能告诉我应该怎么做?
【问题讨论】:
标签: function if-statement octave octave-gui