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

5 Ansichten (letzte 30 Tage)
Rima
Rima am 25 Nov. 2012
Kommentiert: Stephen23 am 21 Jun. 2023
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;

Akzeptierte Antwort

Arthur
Arthur am 25 Nov. 2012
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 Kommentare
Matt Fig
Matt Fig am 25 Nov. 2012
There is a run of these requests recently.
Image Analyst
Image Analyst am 25 Nov. 2012
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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by