MATLAB: How to Create loop

digital signal processingdspDSP System Toolboxfir filterloop

hello , i need help tranfroming the following part in loop (remove the repitation 3times)
clear all;
close all;
clc;
f=[0 0.05 0.1 0.15 0.2 0.25 0.3 0.36 0.41 0.5]*2;
A=[0 0 1 1 0 0 1 1 0 0];
l=55;
n=54;
W1=[1 1 1 1 1];
W2=[8 1 8 1 8];
W3=[1 8 1 8 1];
b1=remez(n,f,A,W1);
b2=remez(n,f,A,W2);
b3=remez(n,f,A,W3);
%for the first FIR system
% the frequency response of the system
[H1,w1]=freqz(b1,1,256,1);
% amplitute frequency response


hr1=abs(H1);
% phase frequency response


hphase1=angle(H1);
hphase1=unwrap(hphase1);
% for the second FIR system
[H2,w2]=freqz(b2,1,256,1);
% amplitute frequency response
hr2=abs(H2);
% phase frequency response
hphase2=angle(H2);
hphase2=unwrap(hphase2);
% For the third FIR system
[H3,w3]=freqz(b3,1,256,1);
% amplitute frequency response
hr3=abs(H3);
% phase frequency response
hphase3=angle(H3);
hphase3=unwrap(hphase3);
figure(1)
hold on
plot(w1,hr1,'r-');grid;
plot(w2,hr2);grid;
plot(w3,hr3,'k-');grid;

Best Answer

See Ch 10 of MATLAB Onramp. In particular, lesson 3. However, if you are new to programming, I suggest going through the entire onramp.