My 'fminsearch' optimization function in Matlab isn't running. the output value doesn't change, just keeps showing the same value. What's going wrong?

1 view (last 30 days)
I need to optimize a particular value in a function (Which acts as my objective function), but it doesn't work. In my objective function,I'm calling another function, and the output of that, acts as the input to my main equation which has to be minimized. Is there something wrong that I've done. Here's the code for the objective function, followed by the main program.
function Y = obj_fun(alp) % Objective Function
load input_acc
%Input values for the Function to compute ODI
wn = 1; eta = 0.02; alpha = 0.041945; Fy = 37.847453; gama = 1/2; beta = 1/4; du = 0.226179; dy = 0.020004; k_in = 1891.997954;
signal_new = alp*X_Norm; %' alp' is the function handle in the anonymous function
[~,~,~, ODI ] = test_Newmark_Beta_Nonlin(wn,eta,alpha,Fy,signal_new,gama,beta,du,dy,k_in);
%ODI, which I get from the above function, is the input parameter to Y, which I need to minimize
Y = (0.4 - ODI).^2; %While Y tends to zero, I need alpha_fn to be optimized.*
return
Main Program to find Critical Acceleration
alpha_in = ones(1,32)*10; %Initial Guess
alpha_fn = fminsearch(@(alp) obj_fun(alp),alpha_in); %fminsearch on objective function
signal_fn = alpha_fn*X_Norm; %Using the optimized value of alpha_fn here
[X,Xdot,Xddot,ODI] = test_Newmark_Beta_Nonlin(wn,eta,alpha,Fy,signal_fn,gama,beta,du,dy,k_in);
ODI(end) %Checking whether ODI value has been maximized
  1 Comment
Torsten
Torsten on 16 Jun 2015
Where do you define X_Norm ? Is it a scalar or a vector ?
Is ODI a scalar or a vector (it should be a scalar) ?
Best wishes
Torsten.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!