Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to generate the Typical impulse wave in Matlab ?

Status
Not open for further replies.

Guest
Hi all again,

To generate a typical impulse wave the code I wrote was this and could not get the required shape.

V=1;
T = 0:1e-7:tf;
i = 1;
for t = 0:1e-7:tf,
if t <= tr
X(i) = V * (1-exp(-t/tr));
else
if X(i) > (0.75*V)
X(i) = V * (exp(-t/(tf-tr)));
end
end
i = i + 1;
end

T = T';
X = X';

plot(T,X);
------------------------------------------------------------
What some people tell me is that there is a in-built fn to do the above, please let me know if there is any.

The people who told me r quite busy and r my seniors,so can't force them u know...

Thanks,
H
 
Replies continue below

Recommended for you

H

I can't follow what your code is trying to do, so it is hard to fix. But... below is a rewrite that runs. Also, I think you are calculaing the impulse response to an ODE. For a different type of solution, you could look at ODE solvers, or the impulse function in the control system toolbox. Also, at the command prompt, you can enter &quot;lookfor impulse&quot; to see what type of built in impulse solvers you have available.

John

function test1
tf=1e-6; % Add definition of tf
tr=3e-7; % Add definition of tr
V=1;
T = 0:1e-7:tf;
i = 1;
for t = 0:1e-7:tf,
if t <= tr
X(i) = V * (1-exp(-t/tr));
else
X(i) = V * (1-exp(-t/tr)); % Add definition of X(i)
if X(i) > (0.75*V) % Need value of X(i)
X(i) = V * (exp(-t/(tf-tr)));
end
end
i = i + 1;
end

T = T';
X = X';

plot(T,X);


 
Hey,
Thanx a lot for the solution but it does not reach 1 on the rise and does not reach 75% of the value in the end (i.e. fall time)

Any suggestions...

Also please help me out in the other query (regarding work space)

I'd be really greatful to u.

Thanx,
H
 
Hey,
Thanx a lot for the solution but it does not reach 1 on the rise and does not reach 75% of the value in the end (i.e. fall time)

Any suggestions...

Also please help me out in the other query (regarding work space)

I'd be really greatful to u.

Thanx,
H
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor