How to use default values with deal()?
조회 수: 2 (최근 30일)
이전 댓글 표시
I use the fallowing method in a function to assign parameter values:
parameters = [1,2,3];
temp_param = num2cell(parameters);
[p1,p2,p3] = deal(temp_param{:});
It is possible to use default values somehow (with a simple compressed syntax)?
So if parameters = [1,2] I still want to use [p1,p2,p3] = ... but let p3=0 by default.
댓글 수: 0
채택된 답변
Azzi Abdelmalek
2014년 11월 14일
편집: Azzi Abdelmalek
2014년 11월 14일
parameters = [1 2];
temp_param = num2cell(parameters)
temp_param(numel(temp_param)+1:3)=num2cell(zeros(1,3-numel(temp_param)))
[p1,p2,p3] = deal(temp_param{:})
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!