MATLAB: Too many output arguments

2 ビュー (過去 30 日間)
Leonard
Leonard 2014 年 10 月 3 日
コメント済み: Leonard 2014 年 10 月 3 日
I'm fairly new to MATLAB but it seems to me that the following line should be correct:
[x,y,z] = [1,2,3]
Why am I getting a "Too many output arguments." error?
x,y,z are unused variables and I've even declared them each as zeros(1).
Thanks!

採用された回答

Image Analyst
Image Analyst 2014 年 10 月 3 日
[1,2,3] is an expression that produces a single thing : an array. You are trying to assign the single thing to 3 separate things . That's the explanation. If you want fix, use deal or assign the 3 variables separately in 3 separate lines.
  1 件のコメント
Leonard
Leonard 2014 年 10 月 3 日
Thanks!

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

その他の回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 3 日
x=1
y=2
z=3

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by