Is it possible to make pdf plot from matrix with mean value?

답변 (3개)

Yusuf Suer Erdem
Yusuf Suer Erdem 2021년 12월 24일
Try these codes below please;
clc;
clear;
close all;
Data=rand(32,247);
data_mean=mean(Data,2);
plot(data_mean);
ax = gca;
exportgraphics(ax,'LinePlot.pdf')

댓글 수: 5

Thank you so much for your answer @Yusuf Suer Erdem
But I was looking for 2 things together:
1.probabilty distribution curve of matrix (100*2000)
2.Mean value line
is there any way to show them together. like mean value line is passig through probabilty distribution curve.
Try these codes below;
clc;
clear;
close all;
r2 = randi([1 100],100,2000);
x = r2(:,1);
pd = fitdist(x,'Normal');
m = mean(pd);
x_pdf = [1:0.1:100];
y = pdf(pd,x_pdf);
figure
histogram(x,'Normalization','pdf')
line(x_pdf,y)
ax = gca;
exportgraphics(ax,'LinePlot.pdf')
Yusuf Suer Erdem
Yusuf Suer Erdem 2021년 12월 29일
편집: Yusuf Suer Erdem 2021년 12월 29일
hi Mohammed, if you are having troubles when you change 'r2' make sure your new matrix has 'double' data type. and also if you see there is 'x_pdf = [1:0.1:100];' matrix there. that matrix should have same amount of columns as like your new r2 does.
Maddy
Maddy 2021년 12월 29일
편집: Maddy 2021년 12월 29일
r2 which is P has 100 rows and 2001 columns. and x_pdf giving 1 row and 991 column.
clear;
close all;
r2 = P; % Matrix which is 100x2001 double
x = r2(:,1); %can you please explain this line?
pd = fitdist(x,'Normal');
m = mean(pd);
x_pdf = [1:1:2001]; %is it correct to match the r2 column which is 2001?
y = pdf(pd,x_pdf);
figure
histogram(x,'Normalization','pdf')
line(x_pdf,y)
ax = gca;
exportgraphics(ax,'LinePlot.pdf') %showing error in this line(Error using exportgraphics
Invalid or deleted object).
could u provide me your P matrix. put it in .mat file and share here please.

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

Yusuf Suer Erdem
Yusuf Suer Erdem 2021년 12월 30일
Let's see. I used these codes below and it did not give me error. But the 'P' matrix ' s values are pretty small. So I can not see them clearly on the graph.
x = double(P(:));
That command takes the P matrix and converts it into all column vector because fitdist() requires that.
clc; clear; close all;
load('P.mat');
x = double(P(:));
pd = fitdist(x,'Normal');
m = mean(pd);
x_pdf = [1:0.1:100];
y = pdf(pd,x_pdf);
figure
histogram(x,'Normalization','pdf')
line(x_pdf,y)
ax = gca;
exportgraphics(ax,'LinePlot.pdf')

카테고리

도움말 센터File Exchange에서 Sparse Matrices에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

질문:

2021년 12월 24일

답변:

2021년 12월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by