Optimization with definite integration
2 views (last 30 days)
Show older comments
I have a cost function (sai) which I need to optimize to minimize the difference between three signals (namely power spectral densities).
Syy, S1y and S2y are all same size and are powers spectral and cross spectral densities respectively. L is an integer and stands for length range of integration (ohm) is from zero to 2-3 (depending the on the first peak of frequency) H1_bar and H2bar are as follows:
here is how i defined my optimization function:
if true
% error_norm = @ (x) integral (@ (sai)(Syy - (((0.5*(((sin (sai)+ sinh(sai))/((sin(sai)*cosh(sai))+(cos(sai)*sinh(sai)))))) .* S1y) + ...
(((-1 / (4 * sai)) *(((cos (sai)- cosh(sai))/((sin(sai)*cosh(sai))+(cos(sai)*sinh(sai))))) * sub_length) .* S2y))) .^ 2,0,x) ;
%[x,fval,exitflag,output] = fmincon (error_norm,x0,A,b,Aeq,beq,lb,ub,nonlcon);
end
I am getting error that inner matrix dimension must agreee. When I delete the integration I receive this error (user input value must return a scalar).
- I really deeply appreciate if someone help me out, I am stuck in this part for almost a week
- Also, how may I plot this so I can have an idea what would be the approximate initial guess for optimization.
Thanks ahead :)
0 Comments
Answers (2)
Torsten
on 2 Dec 2015
Edited: Torsten
on 2 Dec 2015
1. Integrate the following functions over big_Omega using MATLAB's "trapz":
Syy*S1y
Syy*S2y
(S1y)^2
S1y*S2y
(S2y)^2.
Let the results be
I1
I2
I3
I4
I5
2. Compute dh1_bar/dsai, dh2_bar/dsai (symbolically).
3. Solve the equation
I1*dh1_bar/dsai + I2*L*dh2_bar/dsai - I3*h1_bar*dh1_bar/dsai - I5*L^2*h2_bar*dh2_bar/dsai - I4*L*(h1_bar*dh2_bar/dsai + h2_bar*dh1_bar/dsai)) = 0
for sai using MATLAB's "fzero".
The sai you get is optimal.
The method used is to simply differentiate "under the integral" with respect to sai and to set the derivative to zero.
Best wishes
Torsten.
3 Comments
Torsten
on 3 Dec 2015
1. When calculating the integrals, you will have to supply the corresponding omega values, too. E.g. I1=trapz(omega,G1).
2. Since fzero can not handle symbolic expressions, you will have to transform dh1_bar and dh2_bar into a function handle. Also define h1_bar and h2_bar as function handles.
3. First try to plot mysai and see where the zero is located before calling fzero.
Best wishes
Torsten.
Torsten
on 2 Dec 2015
Edited: Torsten
on 2 Dec 2015
Why do you integrate with respect to big_omega whereas in the integral you use small_omega ?
What is big_omega ? An interval ?
How do you supply S_yy, S_1y, S_2y ? As a table of values ? As an explicit function ?
sai is a single scalar value ? h1_bar(sai), h2_bar(sai) are single scalar values ?
Best wishes
Torsten.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!