MATLAB: Defining new variables each time a for loop runs

arrayfor loopMATLABmatrix

Hello, I am having problems getting this code to work:
A=zeros(11,1);
for k=1:11
A(k) = (20*log10(RPM2200.y_values.values/(2*10^-5)))
end
I have included my dataset as well.
What I am trying to do is convert these RPM values which are in Pascals to Decibels (these are formatted in a matrix with 1 column and 11 rows), however I want to be able to save each conversion as a new variable. I know my problem is I am trying to assign a vector to a scalar. I am not sure how to change the conversion equations to be a vector that can be assigned to a new variable. I also want to be able to integrate all of the data sets to do the same thing (RPM2200.y_values.values thru RPM6200.y_values.values).
I hope I exampled my problem somewhat well, I'm sorry if I didn't!

Best Answer

datasets = {RPM2200, RPM3200, RPM4200, RPM5200, RPM6200};
num_ds = length(datasets);
A = cell(num_ds, 1);
for k = 1 : num_ds
A{k} = (20*log10(datsets{k}.y_values.values/(2*10^-5)))
end
Related Question