How can I plot a periodic function?
Show older comments
A periodic function f of period
is given by: 
a) Plot the function in
;
I tried the following code but it did not had the expected output
% User-defined variables
interval_start = -4*pi; % Start of the interval
interval_end = 4*pi; % End of the interval
% Generate x-values over the defined interval
x = linspace(interval_start, interval_end, 1000);
% Evaluate the function
y = abs(mod(x, 2*pi));
% Plot the graph
plot(x, y);
xlabel('x');
ylabel('f(x)');
title('Graph of the Function f(x) = |x|');
grid on;
The exected output should be like:

Accepted Answer
More Answers (0)
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
