MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today**New to MATLAB?**

Asked by 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.

*No products are associated with this question.*

Answer by Sean de Wolski
on 29 Apr 2013

Accepted answer

Show 2 older comments

C Zeng
on 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
on 29 Apr 2013

Yes, I do. You may find this Webinar helpful:

https://www.mathworks.com/company/events/webinars/wbnr49643.html

Answer by Azzi Abdelmalek
on 29 Apr 2013

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

## 0 Comments