Expressing changing array.

12 views (last 30 days)
Jason Psimopoulos
Jason Psimopoulos on 7 Dec 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 Comment
Jason Psimopoulos
Jason Psimopoulos on 7 Dec 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!

Sign in to comment.

Answers (0)

Categories

Find more on Entering Commands 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!