# how to title of subplot

1 view (last 30 days)
Answered: Jonas on 29 May 2021
function untitled(country1,state1,country2,state2,names,days,avg_days,dailycases)
if isempty(state1) && isempty(state2)
Index1 = strcmpi(names,country1);
dailydata1= dailycases(Index1,:);
daily_cases1 = movmean(dailydata1, avg_days);
daily__cases1=daily_cases1(1,:)
figure
subplot(2,1,1)
title('19-ee-65')
bar(days(1:end-1),daily__cases1);
Index2 = strcmpi(names,country2);
dailydata2= dailycases(Index2,:);
daily_cases2 = movmean(dailydata2, avg_days);
daily__cases2=daily_cases2(1,:)
subplot(2,1,2)
title('19-ee-66')
bar(days(1:end-1),daily__cases2);
else
Index1 = strcmpi(names(:,2),state1);
dailydata1= dailycases(Index1,:);
daily_cases1 = movmean(dailydata1, avg_days);
daily__cases1=daily_cases1(1,:)
figure
subplot(2,1,1)
title(state1)
bar(days(1:end-1),daily__cases1);
Index2 = strcmpi(names(:,2),state2);
dailydata2= dailycases(Index2,:);
daily_cases2 = movmean(dailydata2, avg_days);
daily__cases2=daily_cases2(1,:)
subplot(2,1,2)
title(state2)
bar(days(1:end-1),daily__cases2);
end
i want to give title '19-ee-65' to graph one and title '19-ee-66' to graph two how i can in IF statement

Jonas on 29 May 2021
call title() after plotting (after bar() ), that should work the normal way