MATLAB Answers

Leonard
0

MATLAB: Too many output arguments

Asked by Leonard
on 3 Oct 2014
Latest activity Commented on by Leonard
on 3 Oct 2014
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!

  0 Comments

Sign in to comment.

2 Answers

Answer by Image Analyst
on 3 Oct 2014
 Accepted Answer

[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 Comment

Leonard
on 3 Oct 2014
Thanks!

Sign in to comment.


Answer by Azzi Abdelmalek
on 3 Oct 2014

x=1
y=2
z=3

  0 Comments

Sign in to comment.