フィルターのクリア

how do we plot enumerated data and real floating point data in the same plot/figure?

72 ビュー (過去 30 日間)
Using the plot command...
How do we plot enumerated values along side real floating point data values within the same plot/figure?
Are there examples on the MathWorks web site? We can use the yyaxis left/right commands to create plots with multiple scales... such as...
...but, can one of them be a value with enumerated states data type?

採用された回答

Devineni Aslesha
Devineni Aslesha 2020 年 1 月 13 日
The y-axis values in the plot function do not support enumerated data types. Refer https://www.mathworks.com/help/matlab/ref/plot.html for more information.
However, this can be made possible by using the yticklabels function in matlab. The enumerated data types can be defined by defining the class ‘BasicColors’ as follows.
classdefBasicColors < Simulink.IntEnumType
enumeration
Red(0)
Yellow(1)
Green(2)
end
end
Save the class as BasicColors.m file. Use the defined class in the below code to plot the enumerated data type along with the real floating point data type.
x = [1 2 3];
[~,y] = enumeration('BasicColors');
z = [25.2 25.9 67.9];
yticklabels(y)
yticks([0 1 2]);
ylim([0 2]);
yyaxis right;
plot(x, z);
Refer the following links for more information.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by