필터 지우기
필터 지우기

How to plot histogram using given data ?

조회 수: 1 (최근 30일)
Safia
Safia 2023년 2월 23일
댓글: Voss 2023년 2월 24일
Hello!
I'm asking if it is possible to insert data in matlab and use them to plot histogram with different colors?
i have already used excel but i need a different form of histogram (bar forms), for example the first bar contains circles, the second contains squares,...
here is my data
Value first Second third
10 0,67 0,66 0,70
20 0,38 0,37 0,42
30 0,26 0,25 0,30
40 0,19 0,19 0,24
50 0,15 0,15 0,21
i need to see "first", "second" and "third" as function of value
Thanks in advance
  댓글 수: 2
Adam Danz
Adam Danz 2023년 2월 23일
> is it possible to insert data in matlab and use them to plot histogram with different colors?
Yes, one set of bars will be generated for each column of data, each with a different color.
data = randn(1000,3)+[-2 2 5];
hold on
histogram(data(:,1))
histogram(data(:,2))
histogram(data(:,3))
> i need a different form of histogram (bar forms)... the first bar contains circles, the second contains squares
Not sure what this means, please elaborate or show us an image.
Safia
Safia 2023년 2월 24일
@Adam Danz hello!
this is what i get with excel ,how to plot this in matlab?

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

채택된 답변

Voss
Voss 2023년 2월 24일
% Value first Second third
M = [ ...
10 0.67 0.66 0.70; ...
20 0.38 0.37 0.42; ...
30 0.26 0.25 0.30; ...
40 0.19 0.19 0.24; ...
50 0.15 0.15 0.21; ...
];
bar(M(:,1),M(:,2:end))
  댓글 수: 2
Safia
Safia 2023년 2월 24일
@Voss thank you very much.
It is possible to modify its form like this
Voss
Voss 2023년 2월 24일
Look into the hatchfill2 function on the File Exchange in the link shared by VBBV.

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

추가 답변 (1개)

VBBV
VBBV 2023년 2월 23일
Check the answer from the below link
May be its hatch property of the bar which should be used. It seems this is not default Matlab property for bar & histogram functions. You need to use the below custom function available from File Exchange.
  댓글 수: 1
Safia
Safia 2023년 2월 24일
@VBBV thank you .This is what i need but at first i don't know how to plot hisotgram in matlab when i already have data

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

카테고리

Help CenterFile Exchange에서 Histograms에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by