Error using == Matrix dimensions must agree.

1 visualización (últimos 30 días)
Alvaro Arenas
Alvaro Arenas el 30 de Mayo de 2015
Editada: Pronoy Das el 25 de Feb. de 2021
Hi, I want a solution to this problem. Someone can help me?
Error in operations (line 5)
elseif c == 'multi'

Respuesta aceptada

Star Strider
Star Strider el 30 de Mayo de 2015
I have no idea what the matrix dimension problem is, since we have only one line of your code. However, the way to compare strings and string variables is to use the strcmp or strcmpi functions.
So the correct syntax for the line you posted would be:
elseif strcmpi(c, 'multi')
  7 comentarios
Star Strider
Star Strider el 16 de Nov. de 2018
@KenoKanawa — My pleasure!
Dunzhi Chen
Dunzhi Chen el 25 de Jun. de 2020
Thanks, this solved my problem!

Iniciar sesión para comentar.

Más respuestas (1)

Pronoy Das
Pronoy Das el 25 de Feb. de 2021
Editada: Pronoy Das el 25 de Feb. de 2021
I came across a similar problem. Simply replace the single quotation marks with the double quotation marks, i.e. replace the line in your code with
c == "multi"

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by