plot half-wave sine in matlab

main.m
% Define x values
x = linspace(-2*pi, 2*pi, 1000);

% Calculate y values for half-wave sine wave
y = sin(x);
y(x < 0) = 0;

% Plot the half-wave sine wave
plot(x,y)
title('Half-Wave Sine Wave')
xlabel('x')
ylabel('y')
218 chars
13 lines

related categories

gistlibby LogSnag