DEALCELL

버전 1.1.0.1 (2.06 KB) 작성자: Jiro Doke
Deals cell elements to variables (similar to DEAL)
다운로드 수: 2K
업데이트 날짜: 2016/9/1

라이선스 보기

DEALCELL Deals cell elements to variables
[A1,A2,A3,...] = DEALCELL(X) assigns elements of cell array X to output lists. It is the same as A1=X{1}, A2=X{2}, A3=X{3}, ..., AN=X{N}. There can be any number of variables (up to the total number of elements in X) on the left hand side. If there are fewer LHS variables than the total number of elements in X, then only the first N elements of X are assigned.

DEALCELL works similarly to DEAL, except that it is specialized for cell array inputs and that the cell array does not have to be passed in as comma-separated lists.

This is a very short code (0 lines), and for cell array dealing, it is faster than DEAL.

The code:
function varargout = dealcell(varargout)

Helpful error messages are sacrificed for efficiency. To enable better error-checking, uncomment the Error Checking section below.

Example: (speed comparison with DEAL)
sys={'hello'; 'yes'; 'no'; 'goodbye'};
tic; % DEALCELL
for id = 1:100000
[a1,b1,c1,d1] = dealcell(sys);
end
fprintf('\nDEALCELL: %1.3f sec (%d iterations)\n', toc, id);

tic; % DEAL
for id = 1:100000
[a2,b2,c2,d2] = deal(sys{:});
end
fprintf('DEAL : %1.3f sec (%d iterations)\n\n', toc, id);
isequal({a1,b1,c1,d1},{a2,b2,c2,d2})

See also DEAL, LISTS, PAREN.

***
This is a simplification to DEAL, to be used with cell arrays specifically. Comments on its usefulness are welcome. Thanks.

인용 양식

Jiro Doke (2024). DEALCELL (https://www.mathworks.com/matlabcentral/fileexchange/10162-dealcell), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R13
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!
버전 게시됨 릴리스 정보
1.1.0.1

Updated license

1.1.0.0

License update

1.0.0.0

Modify help text