% Generate a sine wave signalt = 0:0.01:2*pi;
f = 1;
x = sin(2*pi*f*t);
% Half-wave rectify the sine wave signaly = x;
y(y<0) = 0;
% Plot the original and half-wave rectified signalsfigure;
subplot(2,1,1);
plot(t, x);
title('Original Sine Wave Signal');
xlabel('Time');
ylabel('Amplitude');
subplot(2,1,2);
plot(t, y);
title('Half-Wave Rectified Sine Wave Signal');
xlabel('Time');
ylabel('Amplitude');
409 chars
23 lines
This code generates a sine wave signal, then performs half-wave rectification on the signal, and finally plots the original and half-wave rectified signals.