Expressing changing array.

12 次查看(过去 30 天)
Jason Psimopoulos
Jason Psimopoulos 2020-12-7
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 个评论
Jason Psimopoulos
Jason Psimopoulos 2020-12-7
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!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Entering Commands 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by