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.

Need help on dsp programming using scilab

Status
Not open for further replies.

Marvin_G

Junior Member level 3
Joined
Nov 21, 2011
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,485
hye,can some1 help me here..below is my code..i keep getting error which is "undefined variable w"..and i have no idea why...please help me..tq


clf;
M = input('Please enter the filter length M:');
w = 0:2*%pi/1023:2*%pi;
num = (1/M)*ones(1,M);
den = [1];
// Compute and plot the DTFT
h = freqz(num, den, w);
subplot(2,1,1)
plot(w/%pi,abs(h));mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\%pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/%pi,angle(h));mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\%pi');
ylabel('Phase in radians');
 

hye,can some1 help me here..below is my code..i keep getting error which is "undefined variable w"..and i have no idea why...please help me..tq


clf;
M = input('Please enter the filter length M:');
w = 0:2*%pi/1023:2*%pi;
num = (1/M)*ones(1,M);
den = [1];
// Compute and plot the DTFT
h = freqz(num, den, w);
subplot(2,1,1)
plot(w/%pi,abs(h));mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\%pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/%pi,angle(h));mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\%pi');
ylabel('Phase in radians');

Ok ,here is the working code

Code:
M = input('Please enter the filter length M:');
w = 0:2*pi/1023:2*pi;
num = (1/M)*ones(1,M);
den = [1];

h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,abs(h));%mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));%mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');


---------- Post added at 19:04 ---------- Previous post was at 19:00 ----------

 

Ok ,here is the working code

Code:
M = input('Please enter the filter length M:');
w = 0:2*pi/1023:2*pi;
num = (1/M)*ones(1,M);
den = [1];

h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,abs(h));%mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));%mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');


---------- Post added at 19:04 ---------- Previous post was at 19:00 ----------



hello..i tried this code already but still undefined variable w..i think something wrong with my scilab..T.T
 

hello..i tried this code already but still undefined variable w..i think something wrong with my scilab..T.T

It's Strange! i think it should work ,Did you make any changes to the code ?

could you post the exact error message as it appears ?
 

It's Strange! i think it should work ,Did you make any changes to the code ?

could you post the exact error message as it appears ?

when use my code this error appear

Code:
-->clf;
 
-->M = input('Please enter the filter length M:');
Please enter the filter length M:w = 0:2*%pi/1023:2*%pi;
Undefined variable: w
Please enter the filter length M:num = (1/M)*ones(1,M);
Undefined variable: num
Please enter the filter length M:den = [1];
Undefined variable: den
Please enter the filter length M:// Compute and plot the DTFT
Invalid factor.
Please enter the filter length M:h = freqz(num, den, w);
Undefined variable: h
Please enter the filter length M:subplot(2,1,1)
 !--error 4 
Undefined variable: x

at line      66 of function input called by :  
M = input('Please enter the filter length M:');
 
 
-->plot(w/%pi,abs(h));mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Magnitude Spectrum |H(e^{j\omega})|')
 
-->xlabel('\omega /\%pi');
 
-->ylabel('Amplitude');
 
-->subplot(2,1,2)
 
-->plot(w/%pi,angle(h));mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Phase Spectrum arg[H(e^{j\omega})]')
 
-->xlabel('\omega /\%pi');
 
-->ylabel('Phase in radians');

when using ur code this error appear
Code:
-->M = input('Please enter the filter length M:');
Please enter the filter length M:w = 0:2*pi/1023:2*pi;
Undefined variable: w
Please enter the filter length M:num = (1/M)*ones(1,M);
Undefined variable: num
Please enter the filter length M:den = [1];
Undefined variable: den
Please enter the filter length M:
 
-->h = freqz(num, den, w);
            !--error 4 
Undefined variable: num

 
 
-->subplot(2,1,1)
 
-->plot(w/pi,abs(h));%mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Magnitude Spectrum |H(e^{j\omega})|')
 
-->xlabel('\omega /\%pi');
 
-->ylabel('Amplitude');
 
-->subplot(2,1,2)
 
-->plot(w/pi,angle(h));%mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Phase Spectrum arg[H(e^{j\omega})]')
 
-->xlabel('\omega /\%pi');
 
-->ylabel('Phase in radians');

it is weird..
 

Just try this code ,

Code:
M = 10;
w = 0:2*pi/1023:2*pi;
num = (1/M)*ones(1,M);
den = [1];

h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,abs(h));%mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));%mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');
 

Just try this code ,

Code:
M = 10;
w = 0:2*pi/1023:2*pi;
num = (1/M)*ones(1,M);
den = [1];

h = freqz(num, den, w);
subplot(2,1,1)
plot(w/pi,abs(h));%mtlb_grid
title('Magnitude Spectrum |H(e^{j\omega})|')
xlabel('\omega /\pi');
ylabel('Amplitude');
subplot(2,1,2)
plot(w/pi,angle(h));%mtlb_grid
title('Phase Spectrum arg[H(e^{j\omega})]')
xlabel('\omega /\pi');
ylabel('Phase in radians');

tried your code already..same error
Code:
-->M = 10;
 
-->w = 0:2*pi/1023:2*pi;
          !--error 4 
Undefined variable: pi

 
 
-->num = (1/M)*ones(1,M);
 
-->den = [1];
 
-->
 
-->h = freqz(num, den, w);
                      !--error 4 
Undefined variable: w

 
 
-->subplot(2,1,1)
 
-->plot(w/pi,abs(h));%mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Magnitude Spectrum |H(e^{j\omega})|')
 
-->xlabel('\omega /\pi');
 
-->ylabel('Amplitude');
 
-->subplot(2,1,2)
 
-->plot(w/pi,angle(h));%mtlb_grid
       !--error 4 
Undefined variable: w

 
 
-->title('Phase Spectrum arg[H(e^{j\omega})]')
 
-->xlabel('\omega /\pi');
 
-->ylabel('Phase in radians');

your code is for matlab is it? im using scilab by the way..
 

Since it's Scilab the code need to be modified.
 
Last edited:

h = freqz(num, den, w);

Does Scilab Support freqz Function ?

I think it has freq function .
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top