Help writing a Unit Step function for a signal!
21 次查看(过去 30 天)
显示 更早的评论
This is NOT homework but part of a project and no matter how many times I've googled this I just keep getting confused.
I am asked to put this function into MatLab, and then have it plot it. Then delay the signal by two seconds (t-2), and plot that on a separate graph.
I have scanned what is being asked of me into a pic so you can understand this better, my problem is I do not know where to start.
0 个评论
回答(2 个)
KSSV
2016-10-3
clc; clear all ;
T = linspace(0,7) ;
V = zeros(size(T)) ;
for i = 1:length(T)
t = T(i) ;
if t<=2
v = exp(-2*t) ;
elseif t>2 && t<=3
v = 10*t-30 ;
elseif t >3 && t <= 5
v = -10*t+50 ;
elseif t > 5 && t <= 7
v = 10*t-70 ;
end
V(i) = v ;
end
plot(T,V)
The above code defines v(t). I hope you should proceed with the other questions.
Sally Al Khamees
2017-2-21
If you have R2016b, you can just use the piecewise function:
t= linspace(0,7);
syms y(t)
y(t) = piecewise(t<=2,exp(-2*t),2<t<=3,10*t-30,3<t<=5,-10*t+50, 5<t<=7, 10*t-70);
fplot(y)
xlim([-1,7])
ylim([-20.0 20])
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!