Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

how to generate time_step in matlab code

Status
Not open for further replies.

andy2000a

Advanced Member level 2
Joined
Jul 18, 2001
Messages
597
Helped
14
Reputation
28
Reaction score
8
Trophy points
1,298
Activity points
5,298
Hi
How to use matlab write a Low_pass filter .. I can use simulink for
simulation , but I want to know how to write a matlab code..

simulink file can novert to Matlab code or not ??

a low pass filter = 1/ (s+1) = e^(-t)

but how to descript expt(-t) in matlab code ??


thank you
 

To write e^(-t)=exp(-t)
also to have an interval of time in order to see your functions write
n=0:1:100 for example. 0 the strarting point 100 final point 1 step of time

Hope i helped
 

Hi
a simple 1 order Low_pass filter can be said Y= 1 /(s+1)
from DSP book
y= 1 / (s+a) ---> e^(-at)

if I use Matlab write
x=[0:1:100];
y=exp(-x);
plot(x, y);

but plot time response is from 1 --> 0

in real circuit is R=10k C=100u , time response from 0->1
time_constant = 4 sec ,
I also use simlink simulation it is ok , but how convert simulink to matlab
? by the way , simulink have "scope" can see "time response"
but if I want to see "frequency domain" like hspice .ac simulation
ho wshould I do ..

thank you
 

answer :

t=[0:1:10];
y= 1- exp(-t);
plot(t, y);


by the way , have anone use Dolphin smash ABCD language ?
I try use smash behavior simulation low pass filter ..
but no detail manual about ..
 

That is a standard issue.

Use substitution s->a*(1+z^(-1))/(1-z^(-1))

then you get an expression which could be easy translated to a Matlab formula.
 

If you have signal processing box installed, function 'freqs' is also useful. **broken link removed**

regards
 

If you want to implement the transferfunction 1/s+1 in Matlab:

Y= Tf([1],[1 1]);

%Plot the Bodediagram
figure
Bode(Y)

Greetz E-goe
 

andy2000a said:
Hi
How to use matlab write a Low_pass filter
thank you

you can use butterworth, write "help butter" in command window or Chebyshev type I digital and analog filter design write "help cheby1",
 

try this code,

Code:
% Filter Construction
fsample=2000;
frmsz=128;
f1=50;
f2=400;
t=(1:frmsz)/fsample;

yt=sin(2*pi*f1*t)+sin(2*pi*f2*t);
subplot(2,2,1)
plot(t,yt);
title('Input signal (time domain)')
xlabel('time (sec)')
ylabel('AMP.')

f=(1:frmsz/2)*fsample/frmsz;
yf=abs(fft(yt));
subplot(2,2,2);
plot(f,yf(1:frmsz/2))
title('Input signal (freq domain)')
xlabel('freq (hz)')
ylabel('AMP.')

forder=10;
fcutoff=200;
wn=fcutoff/(fsample/2);
[b,a]=butter(forder,wn,'low');
[H,w]=freqz(b,a,512);
w=w*fsample/2/pi;
plot(w,20*log10(abs(H)))
title('filter frequency response')
xlabel('freq (hz)')
ylabel('Magnitude (DB)')

ytfiltered=filter(b,a,yt);
subplot(2,2,3);
plot(t,ytfiltered);
title('Output signal (time domain)')
xlabel('time (sec)')

yff=abs(fft(ytfiltered));
subplot(2,2,4);
plot(f,yff(1:frmsz/2));
title('Output signal (Freq domain)')
xlabel('freq (hz)')
ylabel('AMP.')
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top