Finding the Power density function

조회 수: 3 (최근 30일)
Christina Reid
Christina Reid 2021년 2월 3일
댓글: Christina Reid 2021년 2월 3일
I am trying to find the power density function of the 8 datasets, attached below. Can anyone help me?
  댓글 수: 3
Hiro Yoshino
Hiro Yoshino 2021년 2월 3일
Basic approach could be FFT.
Also if you have any question on your code, you should use code format from the tooltip like this:
a = 1
b = 2
x = 1:10
y = sin(a*x)
Also you may want to have a good read of the guideline to get answers quickly.
Christina Reid
Christina Reid 2021년 2월 3일
Thank you. I got the PDF, but still having issues with the for loop. I tried indexing it, but now I get all 0's in colums 2-7....
%% import packages %%
%pkg load statistics
%pkg load signal
%% import values %%
fid=fopen('Data1.txt','r');
data1=fscanf(fid,'%f');
fclose(fid);
fid=fopen('Data2.txt','r');
data2=fscanf(fid,'%f');
fclose(fid);
fid=fopen('Data3.txt','r');
data3prime=fscanf(fid,'%f');
fclose(fid);
data3=zeros(10000,1);
for i= (1:20000);
if mod(i,2)==0;
x=i*0.5;
data3(x)=data3prime(i);
end
end
fid=fopen('Data4.txt','r');
data4=fscanf(fid,'%f');
fclose(fid);
fid=fopen('Data5.txt','r');
data5prime=fscanf(fid,'%f');
fclose(fid);
data5=zeros(10000,1);
for i= (1:20000);
if mod(i,2)==0;
x=i*0.5;
data5(x)=data5prime(i);
end
end
fid=fopen('Data6.txt','r');
data6=fscanf(fid,'%f');
fclose(fid);
fid=fopen('Data7.txt','r');
data7=fscanf(fid,'%f');
fclose(fid);
fid=fopen('Data8.txt','r');
data8=fscanf(fid,'%f');
fclose(fid);
%dataset = [data1,data2, data3, data4, data5, data6, data7,data8]
%% Plot Signal %%
x = (1:10000);
%plot(x,data8(1:10000));
%title('Data8');
%hold on;
%plot(x,data2(1:1000));
%plot(x,data3(1:1000));
%plot(x,data4(1:1000));
%plot(x,data5(1:1000));
%plot(x,data6(1:1000));
%plot(x,data7(1:1000));
%plot(x,data8(1:1000));
%legend('data1','data2','data3','data4','data5','data6','data7','data8');
%hold off;
%PDF = []
%% Probality Density Functions
% finding the PDF for each column
PDF = fft(dataset)
%% Statistical Moment (Mean,StandardDeviation,Skewness and Kurtosis(AKA Flatness Factor))
% col = dataset(:,1:8);
% p1(i) = dataset(i)(:,1)
%% Standard Deviation %%
for i = size(dataset,2)
dataset = [data1,data2, data3, data4, data5, data6, data7,data8];
col(:,i) = dataset(:,i)
end

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import and Export에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by