Operator '==' is not supported for operands of type 'cell'.

24 ビュー (過去 30 日間)
goodwin membreve
goodwin membreve 2020 年 10 月 28 日
回答済み: Ghina Alhunaidi 2021 年 3 月 15 日
eqprompt='Enter Equation (e.g. 2*x^2+4*x+9):';
equation=inputdlg(eqprompt);
eq=str2sym(equation);
syms(symvar(eq));
k=diff(str2sym(equation),var);
disp(k)
in='Do you want to put another equation? [Y or N]:';
n = inputdlg(in,'s');
while n == 'Y'
eqprompt='Enter Equation (e.g. 2*x^2+4*x+9):';
equation=inputdlg(eqprompt);
eq=str2sym(equation);
syms(symvar(eq));
k=diff(str2sym(equation),var);
disp(k)
in='Y or N:';
n = input(in,'s');
end
Is there any operator i can use aside from "=="?

回答 (2 件)

Stephen23
Stephen23 2020 年 10 月 28 日
Use strcmpi instead of testing for character equality.
  4 件のコメント
Stephen23
Stephen23 2020 年 10 月 28 日
while strcmpi(n,'Y')
Do not use == or isequal, unless you really want to annoy the user who enters 'y' instead of 'Y'.
goodwin membreve
goodwin membreve 2020 年 10 月 28 日
oh my god thank you.

サインインしてコメントする。


Ghina Alhunaidi
Ghina Alhunaidi 2021 年 3 月 15 日
code = inputdlg('Please enter the Alphabet Blocks Puzzle code:');
if code==25
fprintf ('Correct code! /n')
else
fprintf ('please try again /n')
code = inputdlg('Please enter the Alphabet Blocks Puzzle code:');
end
for some reason, i keep getting this error (Operator '==' is not supported for operands of type 'cell'. Error in EscapeRoom (line 2)
if code==25) whenever I input a value into the pop-up window and I've tried several functions and it still wont work, what do I have to change in my code to get it to work?

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by