Info
This question is closed. Reopen it to edit or answer.
MAKE OBJECTIVE FUNCTION FROM ALGORITHM
1 view (last 30 days)
Show older comments
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 Comment
Answers (1)
Cris LaPierre
on 2 Aug 2020
You can use the Refactor tool in live scripts to convert selected code to a function. See this page.
0 Comments
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!