How to do normal distribution for same data?

조회 수: 1 (최근 30일)
RoBoTBoY
RoBoTBoY 2022년 11월 16일
댓글: Star Strider 2022년 11월 16일
Hello,
I wrote these lines below, but maybe i'm doing something wrong.
%Import front sonar for 30cm:
sonar_F_030 = readtable('sonar_F_030.csv');
%Split ranges from file
range = sonar_F_030.range;
pd = fitdist(range,'Normal');
mu1 = pd.mu;
sigma1 = pd.sigma;
x = (-3:.1:3);
y = normpdf(range,mu1,sigma1);
plot(x,y)
Error using plot
Vectors must be the same length.
How can I do normal distribution for these data;

채택된 답변

Star Strider
Star Strider 2022년 11월 16일
Try something like this —
%Import front sonar for 30cm:
sonar_F_030 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1195733/sonar_F_030.csv')
sonar_F_030 = 950×2 table
range time _______ ________ 0.3044 0.062361 0.3044 0.12892 0.30696 0.19563 0.30376 0.26228 0.30696 0.32898 0.30376 0.3957 0.30376 0.46234 0.30376 0.52899 0.30759 0.59565 0.3044 0.66232 0.30759 0.72895 0.30312 0.79598 0.3012 0.86278 0.3044 0.92966 0.3044 0.99618 0.3012 1.0629
%Split ranges from file
range = sonar_F_030.range;
pd = fitdist(range,'Normal');
mu1 = pd.mu;
sigma1 = pd.sigma;
% x = (-3:0.01:3);
x = linspace(min(range), max(range)+0.01, numel(range));
y = normpdf(x,mu1,sigma1);
figure
plot(x,y)
grid
Make appropriate changes to get the desired result.
.
  댓글 수: 2
RoBoTBoY
RoBoTBoY 2022년 11월 16일
Thank you very much!
Star Strider
Star Strider 2022년 11월 16일
As always, my pleasure!

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

추가 답변 (1개)

Torsten
Torsten 2022년 11월 16일
%Import front sonar for 30cm:
sonar_F_030 = readtable("https://de.mathworks.com/matlabcentral/answers/uploaded_files/1195733/sonar_F_030.csv");
%Split ranges from file
range = sonar_F_030.range;
pd = fitdist(range,'Normal');
mu1 = pd.mu
mu1 = 0.3035
sigma1 = pd.sigma
sigma1 = 0.0023
x = (0.29:.0001:0.315);
y = normpdf(x,mu1,sigma1);
plot(x,y)

카테고리

Help CenterFile Exchange에서 Exploration and Visualization에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by