Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

MAKE OBJECTIVE FUNCTION FROM ALGORITHM

3 visualizzazioni (ultimi 30 giorni)
jason law
jason law il 11 Mag 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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);

Risposte (1)

Cris LaPierre
Cris LaPierre il 2 Ago 2020
You can use the Refactor tool in live scripts to convert selected code to a function. See this page.

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by