Clear Filters
Clear Filters

How can I name different plots?

1 view (last 30 days)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 25 Oct 2017
Commented: MAHMOUD ALZIOUD on 27 Oct 2017
hello Everyone ,
I draw a lot of monthly data plot by a for loop from 1 to K, and each plot depends on the inputs from every month. I want to make a statement in each plot saying (This Month is 1, OR 2 or etc.). how can I please do that? the month variable in my code is called month and it is from 1 to 12.
  2 Comments
KSSV
KSSV on 26 Oct 2017
How many plot you have K number of plots?
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 26 Oct 2017
I have 12 plots, each plot represents one month in the year, so K is 12 please

Sign in to comment.

Accepted Answer

KSSV
KSSV on 27 Oct 2017
months = {'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','sep','oct','Nov','Dec'} ;
for i = 1:12
data = rand(10,1) ;
h(i) = figure ;
plot(data) ;
title(months{i}) ;
end
  2 Comments
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 27 Oct 2017
thank you very much for the answer, i will try it tomorrow and i will let you know what happened. best regards
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 8 Nov 2017
Edited: MAHMOUD ALZIOUD on 8 Nov 2017
Dear Mr KSSV, I have two cards, one for january and one for july, the months then must be 1 and 7. I wrote this code in order to plot a histogram for each card with the suitable title, how can I please index the variable TandLoad so I can have two histograms with each card data in each histogram? Note that K here is 2 because I have 2 cards just. when i run this code it gives me the histogram for july twice !! where is january one?
for K = 1 : length(directory)
filename = directory(K).name;
xtn1=Class9_data(:,15)*0.1*3.28084; %distance between A & B in ft
Tand1= Class9_data(xtn1(:,1)>3.28 & xtn1(:,1)<8 , :);
xtn2=Class9_data(:,17)*0.1*3.28084; %distance between B & C in ft
Tand2 = Class9_data(xtn2(:,1)>3.28 & xtn2(:,1)<8 , :);
xtn3=Class9_data(:,19)*0.1*3.28084; %distance between C & D in ft
Tand3 = Class9_data(xtn3(:,1)>3.28 & xtn3(:,1)<8 , :);
xtn4=Class9_data(:,21)*0.1*3.28084; %distance between D & E in ft
Tand4 = Class9_data(xtn4(:,1)>3.28 & xtn4(:,1)<8 , :);
TandemData=[Tand1;Tand2;Tand3;Tand4];
TandemLoad=[100*(Tand1(:,14)+Tand1(:,16));100*(Tand2(:,16)+Tand2(:,18));100*(Tand3(:,18)+Tand3(:,20));100*(Tand4(:,20)+Tand4(:,22))]; %it is multiplied by 100 because the units of weight are 100 kgm
figure
histogram(TandemLoad)
months = unique(Ans_7 (K)) ;
xlabel('Weight in Kg')
ylabel('Counts')
title(['ALS for C9 Tandem For Month ',num2str(months)])
end

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!