abs(x.^2)
19 次查看(过去 30 天)
显示 更早的评论
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
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
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
2022-5-3
3 个评论
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
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!