How to model a ramp input with two slopes and saturation at zero?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I am working on a model which I should define an input as following:
- Start time: 0
- A ramp input with slope of 0.1 up to t=10s;
- Continuing with another ramp input with slope of -0.5 after t=10s and saturation at zero.
- No negative values for amplitude and the run time=50s.
I was wodering how it is possible to model this input data using for/while loop in MATLAB!
Any assistance is highly appreciated!
0 Kommentare
Antworten (1)
Les Beckham
am 22 Mär. 2022
Bearbeitet: Les Beckham
am 22 Mär. 2022
One approach (no loops necessary)
t=0:0.1:50;
y = zeros(size(t));
y(t<10) = 0.1 * t(t<10);
y(t>=10) = 1 - 0.5 * (t(t>=10) - 10);
y(y<0) = 0;
plot(t,y, 'linewidth', 2)
grid on
0 Kommentare
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
