Expressing changing array.

조회 수: 13 (최근 30일)
Jason Psimopoulos
Jason Psimopoulos 2020년 12월 7일
댓글: 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