Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

MAKE OBJECTIVE FUNCTION FROM ALGORITHM

조회 수: 1 (최근 30일)
jason law
jason law 2020년 5월 11일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi, Can I know how to make this algorithm to become function in matlab because I want to use fmincon in matlab to find minimum J
f=[];
abs_H=[];
t=[rand(101,2)];
for x=1:101; % number of frequency
for y=1:n; %number of t
Fr(x,y)=cos(2*pi*f(x)*t(y)); %real number of F
Fi(x,y)=-i*sin(2*pi*f(x)*t(y)); % imaginary number of F
end
end
Fr_T=Fr';
Fi_T=Fi';
A=(Fr_T*Fr)+(Fi_T*Fi);
B=(Fr_T*fr)+(Fi_T*fi);
a=lsqminnorm(A,B) ; % solve tp get a set of a
J(z)=sum((a-abs_H))^2; % to find the minimum of J from measured data
end
J_min=min(J);
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 8월 3일
What would be the variable to minimize over?

답변 (1개)

Cris LaPierre
Cris LaPierre 2020년 8월 2일
You can use the Refactor tool in live scripts to convert selected code to a function. See this page.

Community Treasure Hunt

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

Start Hunting!

Translated by