Dear All;
I am trying to fit data to a normal distribution and plot pdf but pdf plot shows several lines , i do not know why it is coming , could you help.
figure is attached

댓글 수: 5

Mustafa Al-Nasser
Mustafa Al-Nasser 2020년 7월 28일
sorry this figure
Turlough Hughes
Turlough Hughes 2020년 7월 28일
What code did you use?
Thank you Hughes for your cooperation
this is the code i use
input1=input(1:1704,:)
input1= smoothdata(input1,'gaussian',5);
input2=input(1705:3533,:)
input2= smoothdata(input2,'gaussian',5);
input3=input(3534:5250,:)
input3= smoothdata(input2,'gaussian',5);
figure(3);
plot(input1);
title('smoothData');
figure(4);
plot(input2);
title('smoothData');
figure(5);
plot(input3);
title('smoothData');
pd1 = fitdist(input1,'Normal')
pd2 = fitdist(input2,'Normal')
pd3 = fitdist(input3,'Normal')
y1 = pdf(pd1,input1);
y2 = pdf(pd2,input2);
y3 = pdf(pd3,input3);
plot(input1,y1,'LineWidth',2)
hold on
plot(input2,y2,'LineWidth',2)
plot(input3,y3,'LineWidth',2)
Turlough Hughes
Turlough Hughes 2020년 7월 28일
Can you provide the data also so we can replicate what you have done, ie the variable input
Mustafa Al-Nasser
Mustafa Al-Nasser 2020년 7월 28일
I extracted the related data part
Many thanks

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

답변 (1개)

Raunak Gupta
Raunak Gupta 2020년 8월 6일

0 개 추천

Hi,
From the code and data provided on question and comment, I see that the output you are plotting is not in sorted order. So basically, what you are currently seeing is the connected line between all the data points which is going in the direction of how the points are arranged in the input vector. For seeing a continuous line either you can sort both the input1 and y1 before plotting (And similarly for other two pairs) or instead of line you can plot circles for every datapoint. This will give correct visualization. Both approaches can be done like below:
% Sorting the input1 and y1 simultaneously
[input1sorted, ind] = sort(input1);
y1sorted = y1(ind);
plot(input1sorted, y1sorted,'LineWidth',2);
% plotting only dot for each datapoints
plot(input1,y1,'o');

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2020년 7월 28일

답변:

2020년 8월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by