creating a sawtooth signal via matlab function block
1 view (last 30 days)
Show older comments
Kamal Ibn Bari
on 19 May 2018
Commented: Ameer Hamza
on 19 May 2018
Hello everyone, I am trying to make a sawtooth signal in simulink via matlab function block, the code:
function y = fcn(t)
y=t-floor(t/1)
end
what i get is something similar to a sawtooth:


the signal does not drop immediately, it take's about 0.8 seconds to drop down to 0 which makes it more like a triangle signal. is there a way to make it more accurate? or maybe is there another way to make a sawtooth signal in simulink via matlab function?
Thanks in advance.
0 Comments
Accepted Answer
Ameer Hamza
on 19 May 2018
Edited: Ameer Hamza
on 19 May 2018
It is because by default the simulation time step size is 0.2 seconds, therefore any update in a signal value will occur after 0.2 seconds hence after 4.8, the value change at 5. To decrease the step size Go to Simulation menu > Model configuration parameters > Solver > Solver Detail and write a small value of step size in place of auto.
2 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!