Hello everyone
This was my code and i was trying to find peak power of the given sin signal.I dont understand how does it really work mathametically?
clc;f=1;
t=1/f;
x=1*sin(2*pi*f*t);
y=max (abs(x).^2);

댓글 수: 2

Martti Ilvesmäki
Martti Ilvesmäki 2022년 5월 3일
.^2 is element-wise power function: https://se.mathworks.com/help/matlab/ref/power.html
abs() is absolute value and complex value function: https://se.mathworks.com/help/matlab/ref/abs.html?s_tid=doc_ta
x.^2 will raise all elements of vector or matrix x to the second power while abs() will take the absolute value of each element in vector or matrix. Using them both together in this case is unnecessary, because using x.^2 will remove all negative values already.
Walter Roberson
Walter Roberson 2022년 5월 3일
That is a formula for peak power, but not with that input. For it to work, the input has to be the fft of the signal (after subtracting the mean)
Your x only has a single sample.
That code with sin() looks like the bare outline of an attempt to calculate fft.

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

 채택된 답변

Malar Vizhi
Malar Vizhi 2022년 5월 3일

0 개 추천

Thankyou then what about this sir
y=mean(x.^2);
if x is array

댓글 수: 3

Martti Ilvesmäki
Martti Ilvesmäki 2022년 5월 3일
The inner operation x.^2 (element-wise power) will be done first and next average of the result is calculated: https://se.mathworks.com/help/matlab/ref/mean.html
I highly recommend referring to Matlab documentation when you are using function you don't understand. The basic functions are well documented with examples and mathematical background included.
Also, please accept my first answer if you found it helpful to your original question. Thank you!
Martti Ilvesmäki
Martti Ilvesmäki 2022년 5월 3일
% Example
x = [1 2 3];
x_squared = x.^2; % --> [1 4 9]
x_squared_mean = mean(x_squared); % --> 4.6667
Default
Default 2023년 8월 5일
편집: Default 2023년 8월 5일
This will fail for complex signals, the more accurate mean will be:
meanx = mean(abs(x).^2);
and the peak will be:
peakx = max(abs(x).^2);

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

추가 답변 (0개)

태그

질문:

2022년 5월 3일

편집:

2023년 8월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by