how to make numbering near "a" like: a1, a2, an

조회 수: 2 (최근 30일)
Rima
Rima 2012년 11월 25일
댓글: Stephen23 2023년 6월 21일
Hi,
Could you please tell me how to increase number near "a" so it could look like this:
b = 1; "ab = something" b = b + 1; ...
a1 = something; a2 = something; ... an = something;

채택된 답변

Arthur
Arthur 2012년 11월 25일
Please don't use dynamic variable names, matlab has plenty of options to store your data in a better way. Use cells or structs.
  댓글 수: 3
Matt Fig
Matt Fig 2012년 11월 25일
There is a run of these requests recently.
Image Analyst
Image Analyst 2012년 11월 25일
If the "a" are being assign to simple numbers (not to strings, structures, cells, etc.), then using a simple numerical array is best and easiest:
for k = 1 : 118
a(k) = b; % a is floating point array, unless you explicitly cast b to an integer type.
b = b + 1; % Whatever.....
end

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

moulay
moulay 2012년 11월 25일
for example_:
% for i=1:2:5
b=['a_' num2str(i)]
end
is that waht are u looking for?

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by