Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

MAKE OBJECTIVE FUNCTION FROM ALGORITHM

1 visualización (últimos 30 días)
jason law
jason law el 11 de Mayo de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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);
  1 comentario
Walter Roberson
Walter Roberson el 3 de Ag. de 2020
What would be the variable to minimize over?

Respuestas (1)

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

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by