Define an array with variable

1 view (last 30 days)
C Zeng
C Zeng on 29 Apr 2013
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.

Accepted Answer

Sean de Wolski
Sean de Wolski on 29 Apr 2013
  5 Comments
C Zeng
C Zeng on 30 Apr 2013
Oh, great! Thanks so much!

Sign in to comment.

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 29 Apr 2013
k=4
assignin('base',sprintf('x_%d',k),[1 2 3])

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!