How to plot several unit steps in a graph without doing it manually?
Show older comments
Hello!
So im currently having some problems with plotting. I have a function that produces my step answer, I now want to plot the results from the function. I have tried done it manually, for example like having it in this form:
y_4 = y_step_4(t);
y_8 = y_step_8(t);
y_53 = y_step_53(t);
hold on;
plot(t,y_4)
plot(t,y_8)
hold off;
function y = y_step4(t)
y = 1 - 2.t*.exp(.2.t);
end
function y = y_step8(t) etc etc
However, this is not a good approach, how would be a better approach to reduce the tedious work of manually plotting it?
This is currently how the code looks like:
%Creates a unit step
create_y_step(4)
function H = transferH(K)
syms s;
% Declaring transfer function G(s)
G = 1/(s*(s+4));
H = (G*K)/(1+G*K);
end
function y = create_y_step(K)
syms s t
H = transferH(K);
y = ilaplace(H*(1/s)); %Unit step
end
%syms t s K
% G = 1/(s*(s+4))
% H = (G*K)/(1+G*K)
% y_step = ilaplace(H*1/s)
All answers and help is greatly appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Calculus 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!