MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

The workspace variable, SelfAssessedHealthStatus, contains four unique values,
Excellent, Fair, Good, and Poor.


Convert SelfAssessedHealthStatus to an ordinal categorical array, such that the
categories have the mathematical ordering Poor < Fair < Good < Excellent.


SelfAssessedHealthStatus = categorical(SelfAssessedHealthStatus,...
{'Poor' 'Fair' 'Good' 'Excellent'},'Ordinal',true);


Summarize the categorical array, SelfAssessedHealthStatus.


summary(SelfAssessedHealthStatus)


Poor 11
Fair 15
Good 40
Excellent 34


Plot Histogram


Create a histogram bar plot directly from a categorical array.


figure
histogram(SelfAssessedHealthStatus)
title('Self Assessed Health Status From 100 Patients')


Plot Categorical Data
Free download pdf