Operator '==' is not supported for operands of type 'tf'

19 visualizaciones (últimos 30 días)
1) Making a dialog box that would take my answers in s1 and compare with s2 and output a cell array.
2) By using the results of the cell array 1 0, 01 or 0 0 i made an if statement to perform calculations
the code runs fine the issue is when press cancel in before i get to this part an error appears as such:

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 10 de Feb. de 2021
The reason:
  1. When you click "cancel" in the inputdlg(), your variable "tf" is not evaluated.
  2. When the second part of the code is executed, it regards "tf" as the built-in tf() function.
  3. You can replicate the same error by doing this "clear tf; tf(1)==1'
  4. Easiest solution is to name variable "tf" to something else. But still you need to handle the cituation where the variable is not evaluated when "cancel" is clicked.
  3 comentarios
Ronald Godagandeni Dewage
Ronald Godagandeni Dewage el 11 de Feb. de 2021
ill tried to return the script once clicked cancel, basically the 'answer' variable cell become blank when clicked cancel. how do i use tht infromation to stop the script from running.
i tried:
if answer(1)==isempty(1)
return
end
it doesnt work
Fangjun Jiang
Fangjun Jiang el 11 de Feb. de 2021
if isempty(answer)

Iniciar sesión para comentar.

Más respuestas (1)

David Hill
David Hill el 10 de Feb. de 2021
if tf %already logical
end

Community Treasure Hunt

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

Start Hunting!

Translated by