Too many output arguments, simple but useful question
조회 수: 8 (최근 30일)
이전 댓글 표시
Hi, I'm trying to get the following code (simplified) running but I don't get the clue how:
a = 3; b=2; c=1;
lol = [1 2 3];
[a b c] = lol;
I get the error "Too many ouptut arguments" and I understand, that this occurs as soon as I request too many outputs from a function/expression. How may I now tell the variable "lol" to split up in 3 arguments?
(In my special case, I'm using str2double(aCellArray) instead of the variable lol)
Thanks a lot and sorry for this rather dumb question xD
댓글 수: 1
Fangjun Jiang
2011년 9월 2일
What are you trying to do? Are you trying to assign multiple variables at a time?
답변 (3개)
the cyclist
2011년 9월 2일
Here is one kludgy way:
a = 3; b=2; c=1; lol = [1 2 3];
lolCell = num2cell(lol);
[a b c] = lolCell{:}
댓글 수: 0
Grzegorz Knor
2011년 9월 2일
I suggest to write own function, something like this:
function varargout = split(a)
for k = 1:nargout
varargout{k} = a(k);
end
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!