Reputation: 935
I am trying to concatenate a variable with a string. For example I want to get d1, d2 and d3.
I know that to concatenate 'd' with 1 , 'd' with 2 and 'd' with 3 , it is necessary to convert 1, 2 and 3 to string. The code below work very well :
['d' num2str(1)] = 4;
['d' num2str(2)] = 5;
['d' num2str(3)] = 6;
But when I tried the code below:
for i=1:3
['d' num2str(i)] = i+3;
end
Unfortunately I always get the error : An array for multiple LHS assignment cannot contain LEX_TS_STRING
Any help will be very appreciated.
Upvotes: 2
Views: 1437