% menu for plotting graphs
disp("Choose the plot style:");
disp("1. Two Plots in One Graph");
disp("2. Two Subplots in One Figure");
choice = input("Enter you choice (1 or 2): ");
% data time point
time = [];
% data PM2.5 = 23, 32
pm2_5 = [];
% data for N02 concentration = 20, 15
NO2 = [];
% start inputting
i = 1;
x = 0;
while true
fprintf("Input data for Time Point %i (Enter -1 to finish):\n", i);
x = input("Enter PM2.5 concentration (ug/m3):");
if x == -1
break
else
pm2_5 = [pm2_5 x];
end
x = input("Enter N02 concentration (ppb):");
if x == -1
break
else
NO2 = [NO2 x];
end
time = [time i];
i = i + 1;
end
% display time, pm2_5, NO2 for checking
disp(time);
disp(pm2_5);
disp(NO2);
% plot graphs with condition
if choice == 1
subplot(1, 1, 1);
plot(time, pm2_5, 'ob', time, NO2, 'dr');
grid on;
else
subplot(2, 1, 1);
plot(time, pm2_5, 'ob');
grid on;
subplot(2, 1, 2);
plot(time, NO2, 'dr');
grid on;
end
Choose the plot style:
1. Two Plots in One Graph
2. Two Subplots in One Figure
Enter you choice (1 or 2):
1
Input data for Time Point 1 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
23
Enter N02 concentration (ppb):
20
Input data for Time Point 2 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
32
Enter N02 concentration (ppb):
15
Input data for Time Point 3 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
-1
1 2
23 32
20 15
Choose the plot style:
1. Two Plots in One Graph
2. Two Subplots in One Figure
Enter you choice (1 or 2):
2
Input data for Time Point 1 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
23
Enter N02 concentration (ppb):
20
Input data for Time Point 2 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
32
Enter N02 concentration (ppb):
15
Input data for Time Point 3 (Enter -1 to finish):
Enter PM2.5 concentration (ug/m3):
-1
1 2
23 32
20 15