필터 지우기
필터 지우기

I have a file name 'partOneData.mat how do I load the data and create a histogram from Matlab.

조회 수: 1 (최근 30일)
I have a file name 'partOneData.mat how do I load the data and create a histogram from Matlab.
I have this but it does not seem to work close all;
commandwindow;
%loads mat file
a = load('partOneData.mat');
figure;
hist(a);
  댓글 수: 2
Adam Danz
Adam Danz 2019년 1월 10일
What doesn't it work? Are you getting an error message? If yes, please copy and paste it here; if no, please specify what's wrong.
I'm assuming the variable you're trying to plot is named 'a'.
Lastly, if you're using a more recent version of matlab, use histrogram() instead of hist().
G. Nardi
G. Nardi 2019년 1월 10일
Thank you for your reponse this is the error
Error using histogram
Expected input number 1, x, to be one of these types:
double, single, uint8, uint16, uint32, uint64, int8, int16, int32, int64, logical, datetime, duration
Instead its type was struct.
Error in histogram>parseinput (line 250)
validateattributes(x,{'numeric','logical','datetime','duration'},...
Error in histogram (line 145)
[opts,passthrough,dispatch] = parseinput(args,firstaxesinput);
Error in Takahashi_Week1 (line 8)
histogram(a)

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

채택된 답변

Adam Danz
Adam Danz 2019년 1월 10일
편집: Adam Danz 2019년 1월 10일
First read about the output to the load() funciton:
The output is a structure containing fields for each variable in the file.
Suppose the variable you're trying to plot is named 'data'
a = load('partOneData.mat'); %'a' is a structure
figure
histogram(a.data) % 'data' is the name of the variable you're plotting
Also see this example:

추가 답변 (0개)

카테고리

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