MATLAB: Store variables with ascending names in array

loopPartial Differential Equation Toolboxvariables

Hello,
Can somebody help me with that?
I am using the PDE toolbox in matlab and I have to create ns and sf variables using the following code.
ns = char('R1','R2','R3','R4','R5','R6','R7');
ns = ns';
sf = 'R1+R2+R3+R4+R5+R6+R7';
It is easy when you have to do it 7 times but I need to do it 12500!!! I believe I need to create variables with ascending names and store them in ns and then add them in sf but I cannot do it!
Many thanks

Best Answer

Hello,
Use this for creating as many variables as you want:
for i=1:10 %I have taken 10 just for example and explanation. You can take 12500.
s1 = 'R';
s2 = num2str(i);
s = strcat(s1,s2)
end
Copy and paste above code on command window to understand properly.