How to Create loop
Show older comments
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;
2 Comments
Stephen23
on 2 Nov 2020
"(remove the repitation 3times)"
Get rid of the pseudo-indices in the variables names (bad data design) and replace them with actual indexing into one variable (best data design), possibly in a loop if required. Indexing and loops are explained here:
sukam
on 2 Nov 2020
Accepted Answer
More Answers (0)
Categories
Find more on Filter Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!