Hello everyone, I am trying to plot from a .mat file called Database which is a 3x5 matrix that contains in each element a 3001x11 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

댓글 수: 2

Adam
Adam 2014년 12월 2일
What is ii?
Andil  Aboubakari
Andil Aboubakari 2014년 12월 2일
편집: Andil Aboubakari 2014년 12월 2일
for ii = 1:numel(manoev)
is the index for the Database matrix (array cell), that I am using to define and take each elements eg. Database{1}
manoev is from 1 to 5, which correspond the 5 column of the Database

댓글을 달려면 로그인하십시오.

 채택된 답변

Thorsten
Thorsten 2014년 12월 2일
편집: Thorsten 2014년 12월 2일

0 개 추천

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

댓글 수: 5

Andil  Aboubakari
Andil Aboubakari 2014년 12월 2일
편집: Andil Aboubakari 2014년 12월 2일
DataBase was made by reading 15 different excel files that have the same variables in common. As part of my task is to plot each of those file against the first column which represent the time from 0-30s
I tried with
for ii = 1:numel(Database)
now I am getting 30 figures instead of 15.
Thorsten
Thorsten 2014년 12월 2일
How to create Database from your 15 files? Can you use the example I've shown above?
As far as I understood, you have 10 variables in each file. Are you trying to plot each variable against the first column in a single subplot, or in different subplots?
Andil  Aboubakari
Andil Aboubakari 2014년 12월 2일
편집: Andil Aboubakari 2014년 12월 2일
I read the 15 files with this (it was your answer from one of my previous questions)
for i = 1:numel(Mach)
for ii = 1:numel(manoev)
DataBase{i,ii} = xlsread((filename),['Dataset_' num2str(Mach(i)) '_u' int2str(manoev(ii))])
because each files have part of name in common,except Mach(0.4,0.204,0.242)
in short: 1 Excel file (3001x11) read to-> One element of database data use to-> figure single subplot of each variables of that file.
Andil  Aboubakari
Andil Aboubakari 2014년 12월 2일
with:
Database(i, j,:,:)
its harder to access each files, if I want to analyse a specific manoev. Having a 3x5 would be easier for me. I manage to do this with 3 loops (each was 1x5) but the code is not efficient as I wanted.
Thorsten
Thorsten 2014년 12월 2일
If you show your solution and say why it is not efficient that I might suggest how to make it more efficient.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

질문:

2014년 12월 2일

댓글:

2014년 12월 2일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by