optimization value not able to acheive
Ältere Kommentare anzeigen
I am not able to get the optimize value of n. Every time it shows Failure in initial objective function evaluation. FSOLVE cannot continue
Below matlab code is given. Thank you
Function
clear all
clc
function F = roo2d(n)
F=[(sin(pi*((n(1)/700)-1))/(pi*((n(1)/700)-1)))^2-0.31;
(sin(pi*((n(1)/1100)-1))/(pi*((n(1)/700)-1)))^2-0.42;
(sin(pi*((n(1)/1500)-1))/(pi*((n(1)/700)-1)))^2-0.50;
(sin(pi*((n(1)/2000)-1))/(pi*((n(1)/700)-1)))^2-0.59;
(sin(pi*((n(1)/2500)-1))/(pi*((n(1)/700)-1)))^2-0.64;
(sin(pi*((n(1)/3000)-1))/(pi*((n(1)/700)-1)))^2-0.655;
(sin(pi*((n(1)/3500)-1))/(pi*((n(1)/700)-1)))^2-0.64;
(sin(pi*((n(1)/4000)-1))/(pi*((n(1)/700)-1)))^2-0.59;
(sin(pi*((n(1)/4500)-1))/(pi*((n(1)/700)-1)))^2-0.50;
(sin(pi*((n(1)/5000)-1))/(pi*((n(1)/700)-1)))^2-0.39];
end
calling a function
fun= @roo2d
n0=[2000];
options = optimoptions('fsolve','Algorithm','levenberg-marquardt');
x= fsolve(fun,n0,options);
Akzeptierte Antwort
Weitere Antworten (1)
That is not what I get when I run your code:
No solution found.
fsolve stopped because the last step was ineffective. However, the vector of function
values is not near zero, as measured by the value of the function tolerance.
Sometiimes it is worthwhile plotting your function to see whether it might have some roots.
t = linspace(800,1e3);
z = zeros(10,length(t));
for i = 1:length(t)
z(:,i) = roo2d(t(i));
end
plot(t,z)
figure
t = linspace(1e3,3e3);
z = zeros(10,length(t));
for i = 1:length(t)
z(:,i) = roo2d(t(i));
end
plot(t,z)
function F = roo2d(n)
F=[(sin(pi*((n(1)/700)-1))/(pi*((n(1)/700)-1)))^2-0.31;
(sin(pi*((n(1)/1100)-1))/(pi*((n(1)/700)-1)))^2-0.42;
(sin(pi*((n(1)/1500)-1))/(pi*((n(1)/700)-1)))^2-0.50;
(sin(pi*((n(1)/2000)-1))/(pi*((n(1)/700)-1)))^2-0.59;
(sin(pi*((n(1)/2500)-1))/(pi*((n(1)/700)-1)))^2-0.64;
(sin(pi*((n(1)/3000)-1))/(pi*((n(1)/700)-1)))^2-0.655;
(sin(pi*((n(1)/3500)-1))/(pi*((n(1)/700)-1)))^2-0.64;
(sin(pi*((n(1)/4000)-1))/(pi*((n(1)/700)-1)))^2-0.59;
(sin(pi*((n(1)/4500)-1))/(pi*((n(1)/700)-1)))^2-0.50;
(sin(pi*((n(1)/5000)-1))/(pi*((n(1)/700)-1)))^2-0.39];
end
There is clearly no time t where all of the curves simultaneously cross 0.
Alan Weiss
MATLAB mathematical toolbox documentation
3 Kommentare
Kundan Prasad
am 9 Dez. 2021
Kundan Prasad
am 9 Dez. 2021
Bearbeitet: Walter Roberson
am 9 Dez. 2021
N = linspace(2000,2500,500);
y = cell2mat(arrayfun(@roo2d, N, 'uniform', 0));
plot(N, y.');
yline(0, 'k')
function F = roo2d(n)
F=[(sin(pi*((n(1)/700)-1))/(pi*((n(1)/700)-1)))^2-0.31;
(sin(pi*((n(1)/1100)-1))/(pi*((n(1)/1100)-1)))^2-0.42;
(sin(pi*((n(1)/1500)-1))/(pi*((n(1)/1500)-1)))^2-0.50;
(sin(pi*((n(1)/2000)-1))/(pi*((n(1)/2000)-1)))^2-0.59;
(sin(pi*((n(1)/2500)-1))/(pi*((n(1)/2500)-1)))^2-0.64;
(sin(pi*((n(1)/3000)-1))/(pi*((n(1)/3000)-1)))^2-0.655;
(sin(pi*((n(1)/3500)-1))/(pi*((n(1)/3500)-1)))^2-0.64;
(sin(pi*((n(1)/4000)-1))/(pi*((n(1)/4000)-1)))^2-0.59;
(sin(pi*((n(1)/4500)-1))/(pi*((n(1)/4500)-1)))^2-0.50;
(sin(pi*((n(1)/5000)-1))/(pi*((n(1)/5000)-1)))^2-0.39];
end
Look at the graph. Near 2250-ish, it crosses 0 for one of the functions -- but when you fsolve() you are asking for all of the functions to be solved.
Kategorien
Mehr zu Signal Processing Toolbox finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!




