How to solve a single nonlinear equation with parameter variations?
Ältere Kommentare anzeigen
#Function file
function f=reso(A,w)
global taue k gamma hac;
f=(((taue+k.^2)-w.^2)*A+(9/2)*A.^3-(75/64)*A.^5).^2+(gamma*k*w*A).^2-hac.^2;
end
Script file
global taue k gamma hac;
taue=0.95;
L=5;
k=pi/(2*L);
hac=1.46;
gamma=0.95;
A0=0.001; %Initial guess
w=0:0.1:5;
for k= 1:length(w)
sol = fzero(@(A) reso(A,w(k)),A0);
plot(w,sol);
end
Here the for loop is not working. Could anybody please point out the problem. Thanks in advance
Akzeptierte Antwort
Weitere Antworten (1)
KSSV
am 30 Jan. 2021
It is suggested not to use global.
Replace these lines:
w=0:0.1:5;
for k= 1:length(w)
sol = fzero(@(A) reso(A,w(k)),A0);
plot(w,sol);
end
with
w=0:0.1:5;
sol = zeros(size(w)) ;
for k= 1:length(w)
sol(k) = fzero(@(A) reso(A,w(k)),A0);
end
plot(w,sol)
Kategorien
Mehr zu Systems of Nonlinear Equations 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!
