Invalid expression, can anybody help me

2 次查看(过去 30 天)
Ali
Ali 2022-12-20
回答: Jan 2022-12-20
x=('heart rate');
switch (x)
case 70
disp('normal')
case 100
disp('HHR')
case 50
disp('LHR')
otherwise
disp('abnormal')
end
  1 个评论
Stephen23
Stephen23 2022-12-20
The code you show does not throw an error (even if it does not do anything useful):
x=('heart rate');
switch (x)
case 70
disp('normal')
case 100
disp('HHR')
case 50
disp('LHR')
otherwise
disp('abnormal')
end
abnormal

请先登录,再进行评论。

回答(1 个)

Jan
Jan 2022-12-20
What is the purpose of:
x=('heart rate');
Afterwards x is the CHAR vector 'heart rate' and you compare it to numerical values. Of course no numberical value matchs this char vector.
Please post the complete message, which mentions the failing line also. The readers cannot guess, which expression is invalid.

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by