How to solve a single nonlinear equation with parameter variations?
古いコメントを表示
#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
採用された回答
その他の回答 (1 件)
KSSV
2021 年 1 月 30 日
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)
カテゴリ
ヘルプ センター および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
