Create Categorical array for histogram on R2020a

조회 수: 3 (최근 30일)
Alessandro Maria Laspina
Alessandro Maria Laspina 2022년 7월 20일
편집: Bruno Luong 2022년 7월 20일
It seems like this example on Histogram plot - MATLAB - MathWorks Italia :
A = [0 0 1 1 1 0 0 0 0 NaN NaN 1 0 0 0 1 0 1 0 1 0 0 0 1 1 1 1];
C = categorical(A,[1 0 NaN],{'yes','no','undecided'})
h = histogram(C,'BarWidth',0.5)
does not work on 2020a.
Any workaround?

답변 (1개)

Steven Lord
Steven Lord 2022년 7월 20일
I tried running those three lines of code in release R2020a and it produced the categorical histogram plot that I expected.
What does "does not work" mean in this context?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.
  댓글 수: 1
Bruno Luong
Bruno Luong 2022년 7월 20일
편집: Bruno Luong 2022년 7월 20일
Steve when I run OP code on my laptop I get this on the command window (R2022a, Windows 11, Intel Irish XE Graphic card, latest driver installed)
h =
Histogram with properties:
Data: [no no yes yes yes no no no no undecided undecided yes no no no yes no ]
Values: [11 14 2]
NumDisplayBins: 3
Categories: {'yes' 'no' 'undecided'}
DisplayOrder: 'data'
Normalization: 'count'
DisplayStyle: 'bar'
FaceColor: 'auto'
EdgeColor: [0 0 0]
Show all properties
Dot indexing is not supported for variables of this type.
Error in matlab.graphics.controls.internal.ToolbarButtonRegistry/getButtonIcon
Error in matlab.graphics.controls.AxesToolbarButton/setStandardIcon
Error in matlab.graphics.controls.AxesToolbarButton/set.Icon
Error in matlab.graphics.controls.AxesToolbarButton
Error in matlab.ui.controls.ToolbarPushButton
Error in matlab.graphics.controls.internal.PostUpdatePlugin.doCacheLoad
Error in matlab.graphics.controls.internal.PostUpdatePlugin>@()matlab.graphics.controls.internal.PostUpdatePlugin.doCacheLoad(canvasParent)
I works fine however if I do this before (may be a work around for OP)
opengl software
on other PC with different (Nvidia graphic card).
Odd and I have no ideat what to chase.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Distribution Plots에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by