After a 5 second google of the title of your thread I found this.Hey guys,
Can anybody help me plot a unit step function in MATLAB? I'm not an experienced programmer and I'm kind of struggling trying to get it right, thanks.
function [x]=unitstep(x)
%This is a unit step "function". The vector keeping track of time is the
%input. If time is negative then a zero is returned. If time is zero than
%0.5 is returned. If time is positive then 1 is returned.
if nargin==0 %demo the use of the function if no input is givenx=-10:10;end
x=x./abs(x); %this performs the same operation as the %matlab "sign"
x(isnan(x))=0;
x=0.5*(x+1);
Thanks for the link, I saw it weeks ago though. The problem is I'm not familiar with the 'function' command in MATLAB, I just wanted to have a simple function like u(t-1) so I can shift the function by varying 't', convolute it with another signal, etc.After a 5 second google of the title of your thread I found this.
Create your own m-file,
Rich (BB code):function [x]=unitstep(x) %This is a unit step "function". The vector keeping track of time is the %input. If time is negative then a zero is returned. If time is zero than %0.5 is returned. If time is positive then 1 is returned. if nargin==0 %demo the use of the function if no input is given
x=-10:10;end x=x./abs(x); %this performs the same operation as the %matlab "sign" x(isnan(x))=0; x=0.5*(x+1);
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Transmission line Unit step function | Homework Help | 0 | ||
Unit-step function | Homework Help | 7 | ||
N | z-Transformation - sketch the system response of the unit step function u(kT) | Homework Help | 0 | |
P | Unit Step Function Integral | Homework Help | 2 | |
N | Calculating power of a signal : Unit step function | Homework Help | 5 |