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.
d(1),d(2)etc. Of course, if you're writing this to a file and have to have it on this format, I guess you can't avoid it. However, I would still recommend keeping it on the formatd(ii)in MATLAB, and useevalc()when you're writing it to the file.