IncVar

버전 1.0.0 (1.3 KB) 작성자: ADragon
Increment Variable class to provide similar functionality to i++
다운로드 수: 11
업데이트 날짜: 2018/7/24

라이선스 보기

IncVar class can increment or decrement a variable when it is called which can simplify code, especially array indexing. Intended to be used as an alternative for i++, but technically it pre-increments the variable, so it's behavior is like ++i.

Example usage (creating a cell array where order is important but not index position):
A{1} = 'The quick';
A{2} = ' brown fox';
A{3} = ' jumps over';
A{4} = ' the lazy';
A{5} = ' dog.';

Can be written as:
i = IncVar;
A{i.i} = 'The quick';
A{i.i} = ' brown fox';
A{i.i} = ' jumps over';
A{i.i} = ' the lazy';
A{i.i} = ' dog.';

Inserting cells into the array does not require editing the indexes:
i = IncVar;
A{i.i} = 'The quick';
A{i.i} = ', stealthy';
A{i.i} = ' brown fox';
A{i.i} = ' launches a triple-twist and'
A{i.i} = ' jumps over';
A{i.i} = ' the lazy';
A{i.i} = ' dog.';

Example usage (indexing for nested for loops):

k = 1;
for i = 1:10
for j = 1:10
A(k) = i*j;
k = k + 1;
end
end

Can be written as:

k = IncVar;
for i = 1:10
for j = 1:10
A(k.i) = i*j;
end
end

인용 양식

ADragon (2024). IncVar (https://www.mathworks.com/matlabcentral/fileexchange/68316-incvar), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R2017a
R2008a 이상 릴리스와 호환
플랫폼 호환성
Windows macOS Linux
카테고리
Help CenterMATLAB Answers에서 Software Development Tools에 대해 자세히 알아보기
태그 태그 추가
도움

도움 받은 파일: inc

Community Treasure Hunt

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

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