How do you vary titles for each row and column for subplots?

10 views (last 30 days)
I have subplots and their titles vary depending on the column and row they are in. How do I vary the title names for each column and row in matlab? For instance, if I choose 2 subjects and 2 extremities, I will have four subplots. I need the first row to be subject 1 and the second to be subject 2. I need column one to be extremity 1 and column two to be extremity 2. The subjects and the extremities change depending on what was chosen in the array before. So if I choose 3 subjects, I would need the last row to be subject 3. Does anyone know the code to do this?
Thanks

Answers (1)

Image Analyst
Image Analyst on 15 Apr 2013
Edited: Image Analyst on 15 Apr 2013
Try this:
counter = 1;
numberOfSubjects = 2;
numberOfExtremities = 3;
for subject = 1 : numberOfSubjects
for extremity = 1 : numberOfExtremities
caption = sprintf('Subject %d, Extremity %d',...
subject, extremity);
subplot(numberOfSubjects, numberOfExtremities, counter);
title(caption, 'FontSize', 20);
counter = counter + 1;
end
end
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
  2 Comments
Amanda
Amanda on 15 Apr 2013
How would I be able to apply it to this code? Note: Subjects and Plotting_Array are arrays or matrices. Num_Col is a number value
%Plotting for Subplots
for i=1:76
clear('data');
x = sum(Subjects);
y = (Num_Cols-1)/x;
figure(x);
for n=2:Num_Cols
subplot(x,y,n-1);
plot(Plotting_Array(:,1),Plotting_Array(:,n));
xlabel('Time (s)');
ylabel('Acceleration (gs)');
title(sprintf('Subject %d', i));
end
end
Image Analyst
Image Analyst on 16 Apr 2013
Sorry for the delay. Do you have this figured out by now, or do you still have questions? If not, what is the size of Plotting_Array?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!