Define an array with variable

Hello, I wonder how can I define an array with a variable, for example,
x_i=an array, where i changes. I do not think Matlab allows such operations. How can I accommodate it? Later on I will use x_i in loops.
Thanks.

 Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 29 Apr. 2013

1 Stimme

5 Kommentare

C Zeng
C Zeng am 29 Apr. 2013
Sean, sorry, another naive question. :0(
Sean de Wolski
Sean de Wolski am 29 Apr. 2013
No worries! That's what we're here for :)
And, as a forum, if we prevent just a few people from creating A1, A2,... An, then we've been successful!
C Zeng
C Zeng am 29 Apr. 2013
Thanks, Sean. Are you working at Mathworks? I use Matlab heavily on computing and I wish I can have opportunity to improve the speed of MATLAB.
Sean de Wolski
Sean de Wolski am 29 Apr. 2013
Yes, I do. You may find this Webinar helpful:
C Zeng
C Zeng am 30 Apr. 2013
Oh, great! Thanks so much!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Azzi Abdelmalek
Azzi Abdelmalek am 29 Apr. 2013

0 Stimmen

k=4
assignin('base',sprintf('x_%d',k),[1 2 3])

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by