Info

This question is closed. Reopen it to edit or answer.

find the maximum of a function when wariables, when matrixes are also involed function.

1 view (last 30 days)
I want to find values of the variables v1,v2 and v3 at which function value is maximum.
F = Em.*exp(1i*ifft(fftshift(sqrt(v1)*Emmf11a+sqrt(v2)*Emmf11b.*exp(-1i*(v3*pi)))
where v1,v2 and v3 are variable for the function and Em, Emmf11a and Emmf11b are in matrix form values and complex.
for example
Em = [1+2i 2;4-1i -12+4i]
Emmf11a = [1+2i 2;4-1i -12+4i]
Emmf11b = [1+2i 2;4-1i -12+4i]
Regards Ali

Answers (1)

Sean de Wolski
Sean de Wolski on 23 May 2013
I would recommend using fminsearch() or patternsearch().
doc fminsearch
doc patternsearch %Global Optimization Toolbox
  3 Comments
Liaquat Ali
Liaquat Ali on 4 Jun 2013
Edited: Liaquat Ali on 4 Jun 2013
my program is like that
function f = myfun(x,Em,Emmf11a,Emmf11b,E_LP)
Eout = Em.*exp(angle(fftshift(ifft2(fftshift...
(sqrt(x(1))*Emmf11a+sqrt(x(2))*Emmf11b.*exp...
(-1i*(x(3)*pi))))))); % 1080 X 1080 matrix
Pow_Eout = sum(sum(abs(Eout).^2));
f = (abs(abs(sum(sum(E_LP.*conj(Eout))))^2)/1.2123/Pow_Eout);
end
and my main program is like that
load Emmf_GI_LP_g20_50um_72m_LCOS % LP-modes of GI-MMF
Emmf11a = E(:,:,5); % 1080 X 1080 matrix
Emmf11b = E(:,:,6); % 1080 X 1080 matrix
load EField_9um_2m_LCOS_100; %E-field of SMF
E_LP = E; % 1080 X 1080 matrix
u1 = 0.5;
u2 = 0.5;
u3 = 0.0;
Emmf_u = sqrt(u1).*Emmf11a + sqrt(u2).*Emmf11b.*exp(1i*(pi*u3));
Emmf_u = fftshift(Emmf_u);
Em = ifft2(Emmf_u); % 1080 X 1080 matrix
[x_fminsearch,fval_fminsearch] = fminsearch(@(x)myfun(x,Em,Emmf11a,Emmf11b,E_LP),[0;0;0],...
optimset('TolX',1e-15));
end
the contraints are V1 + V2 = 1 and 0<=V3<=2*pi is there any other algorithm which i can use ... for finding the values of V1, V2 , V3 to hae the maximum value for f
??

Community Treasure Hunt

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

Start Hunting!