احتاج مساعدة


(system) #1

السلام عليكم ورحمة الله وبركاته
لدي كود بلغة الماتلاب لم افهمه ارجو المساعدة في شرح هذا البرنامج وشكرا

  [SIZE=4][COLOR=forestgreen][FONT=&quot]% dsp filter coefficent calculations[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=black][FONT=&quot]clc;[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]ntaps = 350; [/font][/color][/size][SIZE=4][COLOR=forestgreen][FONT=&quot]% adjust for desired passband/stopband performance[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fs = 48000;[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=black][FONT=&quot]fxlp = 130;  [/font][/color][/size][SIZE=4][COLOR=forestgreen][FONT=&quot]% lowpass transition freq[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fxhp = 100;  [/font][/color][/size][SIZE=4][COLOR=forestgreen][FONT=&quot]% highpass transition freq[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]df = 60;[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=black][FONT=&quot]blp = firpm(ntaps, [ 0 (fxlp-df)/(fs/2) (fxlp+df)/(fs/2) .5]*2, [ 1 1 0 0]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]bhp = firpm(ntaps, [ 0 (fxhp-df)/(fs/2) (fxhp+df)/(fs/2) .5]*2, [ 0 0 1 1]);[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=black][FONT=&quot][hlp wlp] = freqz(blp, 1, 2048);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot][hhp whp] = freqz(bhp, 1, 2048);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]plot(wlp/(2*pi)*(fs/2),db(abs(hlp)), whp/(2*pi)*(fs/2),db(abs(hhp)));[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]title([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'FIR Filter Frequency Responses'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]xlabel([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'Frequency (Hz)'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]ylabel([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'Magnitude (dB)'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]axis([0 800 -60 3]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]grid;[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=forestgreen][FONT=&quot]% dump the coefficients to text files[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fp1 = fopen(sprintf([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'firlp%d.txt'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], ntaps), [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'w'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fp2 = fopen(sprintf([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'firlp%dq15.txt'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], ntaps), [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'w'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]for[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot] i=1:length(blp),[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    comma = [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]','[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot];[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]if[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot] (i==length(bhp))[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]        comma = [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]''[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot];[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]end[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    fprintf(fp1, [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'%f%s
'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], blp(i), comma);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    fprintf(fp2, [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'%d%s
'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], round(2^15 * blp(i)), comma);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]end[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fclose(fp1);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fclose(fp2);[/font][/color][/size][SIZE=4]
  
  [/size][SIZE=4][COLOR=black][FONT=&quot]fp1 = fopen(sprintf([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'firhp%d.txt'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], ntaps), [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'w'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fp2 = fopen(sprintf([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'firhp%dq15.txt'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], ntaps), [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'w'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]for[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot] i=1:length(bhp),[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    comma = [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]','[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot];[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]if[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot] (i==length(bhp))[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]        comma = [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]''[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot];[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]end[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    fprintf(fp1, [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'%f%s
'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], bhp(i), comma);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]    fprintf(fp2, [/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'%d%s
'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot], round(2^15 * bhp(i)), comma);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=blue][FONT=&quot]end[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fclose(fp1);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]fclose(fp2);[/font][/color][/size][SIZE=4]
  [/size][SIZE=4][COLOR=black][FONT=&quot]disp([/font][/color][/size][SIZE=4][COLOR=#A020F0][FONT=&quot]'wrote coefficients to text files.'[/font][/color][/size][SIZE=4][COLOR=black][FONT=&quot]);[/font][/color][/size]