Subplots with titles in the loop
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
KDRA
el 16 de Oct. de 2018
Editada: Kevin Chng
el 16 de Oct. de 2018
Hi! I am trying to plot two graphs (subplot) for left and right side. I have 10 measurements for each side and the measurements were done for 3 people. My code is:
if true
% code
end
for bb = 1:size(Data.Measured,2)
for kk = 1:size(Data.Name,2)
if strcmpi(Data.Side{kk}, 'Right')
subplot(2,1,1)
Data.legend.sub1{c1} = regexprep(Data.Name{kk},'_',' ');
c1 = c1+1;
legend(Data.legend.sub1)
title([name,' Right'])
else
subplot(2,1,2)
title([name,' Left'])
Data.legend.sub2{c2} = regexprep(Data.Name{kk},'_',' ');
c2 = c2+1;
legend(Data.legend.sub2)
end
semilogx(f_aff, Data.Measured{bb}{kk},'linewidth' ,2 )
hold on
grid on
xlim([200 8000])
xlabel('frequency [Hz]')
ylabel('SPL')
end
figure
end
I am getting almost correct results - three figures with two graphs each with left and right side and all measurements inside. However, the variable 'name' containing initials adds up so I don't have three figures for three different people but I have three figures with all people in each title (see screenshot).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/197990/image.png)
I tried everything and putting 'title' line in different order but it didn't really work...
2 comentarios
Kevin Chng
el 16 de Oct. de 2018
i guess you are storing 3 ppl name in the variable name, therefore, try indexing it for each figure.
name(bb)
Respuesta aceptada
Kevin Chng
el 16 de Oct. de 2018
Editada: Kevin Chng
el 16 de Oct. de 2018
Try indexing name for each figure.
name(bb)
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!