Matlap

Discussion in 'Programmer's Corner' started by TAKYMOUNIR, May 27, 2013.

  1. TAKYMOUNIR

    Thread Starter Active Member

    Jun 23, 2008
    351
    1
    Code ( (Unknown Language)):
    1. [FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]
    2. close [/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0]all[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2];
    3. clc;
    4. w=0:.01:2*pi;
    5. x=(1-(.25).^101 .* exp(-1i*101*w)).*(1-(1.5) .* exp(-1i*w))/((1-(.25).^exp(-1i*w)).*(1-(2/3) .* exp(-1i*w)));
    6. magx=abs(x);
    7. phax=angle(x).*180/pi;
    8. subplot(2,1,1);plot(w,magx);
    9. ylabel([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0]'magx'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
    10. xlabel([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0]'\omega,rad/sample'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
    11. subplot(2,1,2);plot(w,phax);
    12. xlabel([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0]'\omega,rad/sample'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
    13. ylabel([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0][FONT=Courier New][SIZE=2][COLOR=#a020f0]'phax'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]);
    14. [/SIZE][/FONT][/SIZE][/FONT]
    Hi when i run the MATLAP i do not have any error message but i can not see waveform ,it is empty ,so what is the problem
    thanks
     
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    What the heck is MATLAP!?:confused::confused::confused:

    If, you meant a 'B' instead of a 'P', then you didn't do your dot-divide, see here:
    Code ( (Unknown Language)):
    1. close all;
    2. clc;
    3. w=0:.01:2*pi;
    4. x=(1-(.25).^101 .* exp(-1i*101*w)).*(1-(1.5) .* exp(-1i*w))[COLOR="Red"][SIZE="7"]./[/SIZE][/COLOR]((1-(.25).^exp(-1i*w)).*(1-(2/3) .* exp(-1i*w)));
    5. magx=abs(x);
    6. phax=angle(x).*180/pi;
    7. subplot(2,1,1);plot(w,magx);
    8. ylabel('magx');
    9. xlabel('\omega,rad/sample');
    10. subplot(2,1,2);plot(w,phax);
    11. xlabel('\omega,rad/sample');
    12. ylabel('phax');
    Since you can't really debug the code, it helps to split your assignments up into incremental assignments, e.g.
    Code ( (Unknown Language)):
    1. close all;
    2. clc;
    3. w=0:.01:2*pi;
    4. x1=(1-(.25).^101 .* exp(-1i*101*w)); [COLOR="YellowGreen"]% 1st part of numerator[/COLOR]
    5. x2 = x1 .*(1-(1.5) .* exp(-1i*w));  [COLOR="YellowGreen"]% second part of numerator[/COLOR]
    6. x3 = ((1-(.25).^exp(-1i*w)).*(1-(2/3) .* exp(-1i*w))); [COLOR="YellowGreen"]% denominator[/COLOR]
    7. x = x2 ./ x3; [COLOR="YellowGreen"]% do the division[/COLOR]
    8. magx=abs(x);
    9. phax=angle(x).*180/pi;
    10. subplot(2,1,1);plot(w,magx);
    11. ylabel('magx');
    12. xlabel('\omega,rad/sample');
    13. subplot(2,1,2);plot(w,phax);
    14. xlabel('\omega,rad/sample');
    15. ylabel('phax');
    16.  
     
    TAKYMOUNIR likes this.
  3. Wendy

    Moderator

    Mar 24, 2008
    20,765
    2,535
    This is not really math, but software, so I am moving it.
     
Loading...