Error using == Matrix dimensions must agree.

10 ビュー (過去 30 日間)
Alvaro Arenas
Alvaro Arenas 2015 年 5 月 30 日
編集済み: Pronoy Das 2021 年 2 月 25 日
Hi, I want a solution to this problem. Someone can help me?
Error in operations (line 5)
elseif c == 'multi'

採用された回答

Star Strider
Star Strider 2015 年 5 月 30 日
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 件のコメント
Star Strider
Star Strider 2018 年 11 月 16 日
@KenoKanawa — My pleasure!
Dunzhi Chen
Dunzhi Chen 2020 年 6 月 25 日
Thanks, this solved my problem!

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

その他の回答 (1 件)

Pronoy Das
Pronoy Das 2021 年 2 月 25 日
編集済み: Pronoy Das 2021 年 2 月 25 日
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"

カテゴリ

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