Effacer les filtres
Effacer les filtres

How could I find the power of the periodic signal on my code assuming it is either a voltage or a current waveform with a normalized load resistance of 1 Ohm and plot it.

2 vues (au cours des 30 derniers jours)
A = 1.15;
t = linspace(-2, 1, 1000);
a = exp(-0.5*t);
y = A*a.*(sin(2*pi*3*t)) .* (ustep(t+2)-ustep(t));
figure
plot(t, y, 'LineWidth', 2)
xlabel('t');
ylabel('y');
title('L2E2');
grid on;
env = envelope(y, 10, 'analytic'); % Signal Envelope
Lv = env > min(env); % Extract Signal Boundaries
repeats = 10;
yv = repmat(y(Lv), 1, repeats); % Replicate Signal
tv = (0:numel(yv)-1) * (t(2)-t(1)); % Create Corresponding Time Vector
figure
plot(tv,yv)
grid
xlim([min(tv) max(tv)])
title('L2E2')
xlabel('t')
ylabel('y')

Réponses (1)

Nithin
Nithin le 12 Oct 2023
Hi Roberto,
I understand that you want to find the power of a given periodic signal with a normalized load resistance of 1 ohm and plot it.
To implement this, kindly refer to the following code snippet -
% Calculate the power of the signal
T = t(end) - t(1); % Calculate the period of the signal
instantaneous_power = abs(y).^2;
power = (1/T) * trapz((t, instantaneous_power) / load_resistance));
disp(['The power of the signal is: ' num2str(power) ' Watts']);
To plot the power of the signal, kindly refer to the following code snippet -
Figure
plot(t, instantaneous_power, 'LineWidth', 2)
xlabel('t');
ylabel('Power');
title('Power of the Signal');
grid on;
For more information regarding “trapz” and “plot” functions, kindly refer to the following documentation:
I hope this answer resolves your query.
Regards,
Nithin Kumar.

Community Treasure Hunt

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

Start Hunting!

Translated by