Using fzero solving function between two bounds
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all.
I have tried to search up this issue I am having with the search function and have tried to find similar implementations but so far turned up nothing! This is my first time asking a question on here so please feel free to ask anything I haven't offered to help solve the issue.
I am trying to solve for an angle phistar between two bounds, sim,epsilon (1e-6) and pi/2 if f_func @ pi/2 > 0.
f_func is a function containing more than just the angle variable.
f_func returns decimals, both positive and negative of magnitude less than 2 when I run the main script.
When I run my main code, I get this error. This doesn't make sense to me as my interval endpoints are finite and real?!?
I have tried implementing fsolve, lsqnonlin and fminsearch but to no avail.
Can anyone suggest an alternative solving function or see any errors in the function syntax?

function [phistar] = BEMSOLVE(phiv,rotor,sim)
%%% Function to solve Blade Element Momentum Theory Equations via Ning's Implementation
if f_func(pi/2,rotor,sim) > 0
phistar = fzero(@(phiv) f_func(phiv,rotor,sim),[sim.epsilon,pi/2]);
elseif (fPB_func(-pi/4,rotor,sim) < 0 && fPB_func(sim.epsilon,rotor,sim) > 0)
phistar = fzero(@(phiv) fPB_func(phiv,rotor,sim),[-pi/4,-sim.epsilon]);
else
phistar = fzero(@(phiv) f_func(phiv,rotor,sim),[pi/2,pi]);
end
6 Kommentare
John D'Errico
am 2 Feb. 2021
fzero CANNOT solve an array. You could use arrayfun, if you know what you are doing, but it is simpler to just use a loop.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Surrogate Optimization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!