string inputs and if else statement

2 views (last 30 days)
function untitled(country1,state1,country2,state2,names,days,avg_days,dailycases)
if state1= isempty and state2 = isempyty
Index1 = strcmpi(names,country1);
dailydata1= dailycases(Index1,:);
daily_cases1 = movmean(dailydata1, avg_days);
daily__cases1=daily_cases1(1,:)
figure
subplot(2,1,1)
title('country1')
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('country2')
bar(days(1:end-1),daily__cases2);
else
Index1 = strcmpi(names,state1);
dailydata1= dailycases(Index1,:);
daily_cases1 = movmean(dailydata1, avg_days);
daily__cases1=daily_cases1(1,:)
figure
subplot(2,1,1)
title('country1')
bar(days(1:end-1),daily__cases1);
Index2 = strcmpi(names,state2);
dailydata2= dailycases(Index2,:);
daily_cases2 = movmean(dailydata2, avg_days);
daily__cases2=daily_cases2(1,:)
subplot(2,1,2)
title('country2')
bar(days(1:end-1),daily__cases2);
end
how i should write code after if statement so that if state =empty
the it execute the if part and else it execute else part
note that country1, country2,state1,state2 they all are string input

Accepted Answer

Star Strider
Star Strider on 28 May 2021
... how i should write code after if statement so that if state =empty ...
This line:
if state1= isempty and state2 = isempyty
becomes:
if isempty(state1) && isempty(state2)
If that is not true (both are not empty), the else section should execute.
.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!