MATLAB: I have a question regarding changing variable names in a loop.

changing variable names in loops

I have the following code:
i=linspace(25,100,4); for x=1:4; cd 'C:\Users\somrsz\Documents\TID\raw data from sea trials april 2016\Matlabformulas' [eval(['Spectrum_numstr(x)'=i;]),~,~]=fft_BW_V3(Info,1/2000,2^15,100,0.001,0); cd 'C:\Users\somrsz\Documents\TID\raw data from sea trials april 2016\waterfall plots' end
Basically what I am trying to do is get the spectrum output of the function fft_BW_V3 to be: Spectrum_25, Spectrum_50, Spectrum_75 … etc… any ideas are much appreciated!
Thanks!

Best Answer

for i = 0:25:100
str = strcat('spectrum','_',num2str(i)) ;
disp(str)
end