Matlab piecewise function tranformation to step and ramp
9 views (last 30 days)
Show older comments
How can I transform piecewise function into ramp and step function? For example, I program matlab where it asks for piecewise function as input and then it takes these functions and decompose it into ramp and step function so that my output will be like a*x(t+n) +..... , where a is the value of the ramp/step a, n is the shift on the x-axis and x defining either ramp( r ) or step ( u )
0 Comments
Answers (1)
Star Strider
on 5 Nov 2020
Experiment with these:
u = @(t) t>0; % Unit Step Function
r = @(t,a,b) (t.*a).*((t>=0) & (t<=b)); % Ramp With Slope ‘a’ And Time Limit ‘b’
t = linspace(0, 5, 250);
figure
subplot(2,1,1)
plot(t, u(t-2.5))
grid
ylim([-1 1]*1.1)
subplot(2,1,2)
plot(t, r(t-0.5, 2, 4-0.5))
grid
ylim([-1 10]*1.1)
.
2 Comments
Star Strider
on 5 Nov 2020
Apparently, this is an assignment or exercise. It would be best if you experiment to produce the desired result from my example functions or functions you write.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!