Error using == Matrix dimensions must agree.

10 views (last 30 days)
Hi, I want a solution to this problem. Someone can help me?
Error in operations (line 5)
elseif c == 'multi'

Accepted Answer

Star Strider
Star Strider on 30 May 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 Comments
Dunzhi Chen
Dunzhi Chen on 25 Jun 2020
Thanks, this solved my problem!

Sign in to comment.

More Answers (1)

Pronoy Das
Pronoy Das on 25 Feb 2021
Edited: Pronoy Das on 25 Feb 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"

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!