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 Kommentare

Stephen23
Stephen23 am 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
sukam am 2 Nov. 2020
i am not familliar with coding can u help modify plz

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Cris LaPierre
Cris LaPierre am 2 Nov. 2020

1 Stimme

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

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by