MATLAB: Choose data and plot from a 3×5 Matrix

matrix manipulationsubplot

Hello everyone, I am trying to plot from a .mat file called Database which is a 3×5 matrix that contains in each element a 3001×11 data, using this loop
for jj=1:numel(variables)-1
subplot(numel(variables)-1,1,jj)% make a subplot
plot(DataBase{ii}(:,1),DataBase{ii}(:,jj+1))
xlabel(variables{1})
ylabel(variables{jj+1})
end
I can plot Database(1,1),Database(1,2),Database(1,3),Database(1,4),Database(1,5) but I this loop doesn't do Database(2,1) and therefore Database(3,1) up to the fifth column of those rows,its just give me empty plots. Same applies if I want to save those plot as jpeg, with specific distinctive names.
print(datafig(ii),'-djpeg')
Thanks in advance

Best Answer

Database is not a 3 x 5 matrix but a cell array with 3 x 5 elements. So your ii should probably run like this:
for ii = 1:numel(Database)
Also it is not quite clear to me what you want to achieve with your subplots. You seem to have 10 variables in column(2:11) for each of your 3 x 5 models that you try to plot against column(1). That will result in 3 x 5 x 10 = 150 subplots. Is that what you want to achieve?
BTW: It would also be easier to store your Dataabase in a 3x5x 3001x11 matrix. Because all entries have the same size you do not need cell arrays:
set = [0.4 0.204 0.242];
manoev = 1:5;
for i = 1:numel(set)
for j = 1:numel(manoev)
filename = ['Dataset_' num2str(set(i)) '_U_' int2str(manoev(j)) '.csv'];
Database(i, j,:,:) = xlsread(filename);
end
end
Related Question