MATLAB: How to plot sawtooth wave sawtooth function

functionsawtooth

Best Answer

You are very close.
Try this:
f = @(x) rem(x+3,2)-1
figure
fplot(f, [-3,3])
It offsets the ‘x’ value, subtracts 1 so the limits are appropriate, then does the plot.
It may not be universally applicable, for all ‘x’. It works here for this particular problem.