creating user defined blocks

Started by krishna_31985 February 14, 2006
hi friends,
    i am doing my project on transmultiplexers.i want to do it in 
simulink.i am trying to create blocks for each one like 
decimator,interpolator.............
         but i always get an error .the following is the 
interpolation program.can anyone tell me how to create a block for 
this in simulink
clf;
dt=0.00005;
t=-0:dt:N-1;
N=input('input length:');
L=input('up-sampling factor:');
f0=input('input signal frequency:');
t=0:50;
n=0:N-1;
xa=sin(2*pi*f0*t);
x=sin(2*pi*f0*n);
y=zeros(1,L*length(x));
y([1:L:length(y)])=x;
subplot(2,1,1);
plot(t,xa);
hold on
stem(n,x);
title('input sequence');
xlabel('time index n');
ylabel('amplitude');
subplot(2,1,2);
stem(n,y(1:length(x)));
title(['output sequence up-sampled by',num2str(L)]);
xlabel('time index n');
ylabel('amplitude');
          thank you.
	
Not sure what you really want, but this appears to just insert zero samples to up-sample the input. Simulink's DSP Blockset has the Upsample block in the Signal Operations section of the  DSP Blockset library, which would do the same, I think.
 
Mark


From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf Of krishna_31985
Sent: Tuesday, February 14, 2006 8:18 PM
To: m...@yahoogroups.com
Subject: [matlab] creating user defined blocks

hi friends,
    i am doing my project on transmultiplexers.i want to do it in
simulink.i am trying to create blocks for each one like
decimator,interpolator.............
         but i always get an error .the following is the
interpolation program.can anyone tell me how to create a block for
this in simulink
clf;
dt=0.00005;
t=-0:dt:N-1;
N=input('input length:');
L=input('up-sampling factor:');
f0=input('input signal frequency:');
t=0:50;
n=0:N-1;
xa=sin(2*pi*f0*t);
x=sin(2*pi*f0*n);
y=zeros(1,L*length(x));
y([1:L:length(y)])=x;
subplot(2,1,1);
plot(t,xa);
hold on
stem(n,x);
title('input sequence');
xlabel('time index n');
ylabel('amplitude');
subplot(2,1,2);
stem(n,y(1:length(x)));
title(['output sequence up-sampled by',num2str(L)]);
xlabel('time index n');
ylabel('amplitude');
          thank you.
****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to D...@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.


Krishna-

> Not sure what you really want, but this appears to just insert
> zero samples to up-sample the input. Simulink's DSP Blockset
> has the Upsample block in the Signal Operations section of the
> DSP Blockset library, which would do the same, I think.

If increased sampling rate is actually the desired result, don't forget to apply anti-aliasing filter after inserting zeros.  The filter should be LPF with cut-off at 1/2 original sampling rate.  Otherwise the 'edges' between samples and zeros contain frequencies higher than that.

-Jeff
 

 

From: m...@yahoogroups.com [mailto:m...@yahoogroups.com] On Behalf Of krishna_31985
Sent: Tuesday, February 14, 2006 8:18 PM
To: m...@yahoogroups.com
Subject: [matlab] creating user defined blocks
hi friends,
    i am doing my project on transmultiplexers.i want to do it in
simulink.i am trying to create blocks for each one like
decimator,interpolator.............
         but i always get an error .the following is the
interpolation program.can anyone tell me how to create a block for
this in simulink
clf;
dt=0.00005;
t=-0:dt:N-1;
N=input('input length:');
L=input('up-sampling factor:');
f0=input('input signal frequency:');
t=0:50;
n=0:N-1;
xa=sin(2*pi*f0*t);
x=sin(2*pi*f0*n);
y=zeros(1,L*length(x));
y([1:L:length(y)])=x;
subplot(2,1,1);
plot(t,xa);
hold on
stem(n,x);
title('input sequence');
xlabel('time index n');
ylabel('amplitude');
subplot(2,1,2);
stem(n,y(1:length(x)));
title(['output sequence up-sampled by',num2str(L)]);
xlabel('time index n');
ylabel('amplitude');
          thank you.


          
         photo                                photo2                            photo3


DSC-00465.jpg
 
DSC-00466.jpg
 
DSC-00467.jpg