Expressing changing array.

15 vues (au cours des 30 derniers jours)
Jason Psimopoulos
Jason Psimopoulos le 7 Déc 2020
I am trying to solve this system in order to optimize a remez algorithm I am working on.The problem is I can not figure out how to calculate the summations with the changing 'cos' because of the n factor. I tried to write a for loop but it creates a matrix which I do not need.
L = 51; %filter length
ws1 = 0.4*pi; % the start of the transition zone
wp1 = 0.5*pi; % the end of the transition zone
Ks1 = 1;
Kp = 2;
wo = (ws1+wp1)/2;
G = 5000; %the grid size
w = [0:(G-1)]*pi/L;
W = Ks1*(w<=ws1) + Kp*(w>=wp1) %the weight function
D = (wp1>=w); %the ideal function
N=(L-1)/2
m=0:N
k=1:4999
F(k)=(W(k).^2).*D(k))*cos(w(k).*m')
I tried to leave the summations out of it and I think this was the closest I got to creating the correct array but it does not work either.I know there is probably something I miss but I only use matlab for couple of days and it really troubles me.
  1 commentaire
Jason Psimopoulos
Jason Psimopoulos le 7 Déc 2020
take it with a grain of salt but in case someone needs this I think this code works.
clc;
clear all;
close all;
L = 51;
ws1 = 0.4*pi;
wp1 = 0.5*pi;
Ks1 = 1;
Kp = 2;
wo = (ws1+wp1)/2;
G = 1000;
w = [0:(G)]*pi/G;
W = Ks1*(w<=ws1) + Kp*(w>=wp1)
D = (wo>=w);
N=(L-1)/2
m=0:N
k=1:1001
for i = 0:N
F(i+1,:)=sum(arrayfun(@(k) (W(k).^2).*D(k).*cos(w(k).*i), 1:1000))
end
Always happy to be corrected!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by