MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1
the Subplot button. You only can add additional subplots to a figure if the figure
contains one subplot. If a figure contains multiple subplots, the Subplot button is
disabled.

For example, suppose that you want to compare the blood pressure of smoking and non-
smoking patients. Create a live script called patients_smoking.mlx and add code that
loads the health information for 100 different patients.

load patients

Run the code by going to the Live Editor tab and clicking Run.

Add a scatter plot that shows the systolic blood pressure of patients that smoke versus
the systolic blood pressure of patients that do not smoke. Run the code.

figure
scatter(Age(Smoker==1),Systolic(Smoker==1));
hold on
scatter(Age(Smoker==0),Systolic(Smoker==0));
hold off

In the Figure tab, select Subplot and choose the layout for two horizontal graphs.

19 Live Scripts and Functions

Free download pdf