How to solve transcendental equations in matlab
23 次查看(过去 30 天)
显示 更早的评论
I am practicing solving transcendental equations in matlab I have the given equation and I want to solve for x
tan(((0.9)*pi/w)*sqrt(1.468^2-x.^2))- sqrt((x.^2-1.458^2))/(sqrt(1.468^2-x.^2))==0
plotting w varies from 1.55 to 5 I tried all day but I cannot find solution, I tried with fzero(fun,xo) without success any suggestion?
5 个评论
Walter Roberson
2018-6-13
Do not close questions that have an Answer. The volunteers spent time responding to you, and their responses may help other people with similar questions.
I know that I spent about 2 hours investigating this myself, and I am disappointed that my contribution would just disappear as if I had never done the work.
采纳的回答
Anton Semechko
2018-6-12
This is a complex-valued function. Just from visual inspection, it is apparent that the real part of this function has infinitely many solutions. The imaginary part, however, appears to have a finite number of zeros. Are those the solutions you are looking for?
x=linspace(-2*pi,2*pi,1E4);
w=1.55;
f=tan(((0.9)*pi/w)*sqrt(1.468^2-x.^2)) - sqrt((x.^2-1.458^2))./(sqrt(1.468^2-x.^2));
figure('color','w')
plot(x,real(f))
hold on
plot(x,imag(f))
set(gca,'YLim',[-10 10])
8 个评论
Anton Semechko
2018-6-12
编辑:Walter Roberson
2018-6-12
If you want to plot w along horizontal axis, change
plot(Z(i),W(i),'.k','MarkerSize',20) to plot(W(i),Z(i),'.k','MarkerSize',20),
plot(Z,W,'-b') to plot(W,Z,'-b')
x- and y-labels would have to be modified accordingly.
Variable Z is a vector that contains solutions to f(x,w)=0, so that abs(f(Z(i),W(i)))<tol, where tol=1E-16. W is vector of w values that go from 1.5 to 5.
Anton Semechko
2018-6-12
Here is modified version of the code and visualization of computed results:
% Equation
a=0.9;
n1=1;
n2=1.5;
f=@(x,w) tan((a*pi/w)*sqrt(n2^2-x.^2)) - sqrt((x.^2-n1^2))./(sqrt(n2^2-x.^2));
% Look for zeros for w=[1.5 5]
W=linspace(1.5,5,1E2);
X=linspace(n1+1E-12,n2-1E-12,1E3);
Z=0.5*(n1+n2)*ones(size(W));
Opt=optimset('Display','off');
figure('color','w')
for i=1:numel(W)
% Initialize search
F=f(X,W(i));
[F_min,id]=min(abs(F));
Z(i)=X(id);
% Refine solution
f_i=@(x) f(x,W(i));
[Zi,Fi]=fzero(f_i,Z(i),Opt);
if abs(Fi)<abs(F_min), Z(i)=Zi; end
plot(W(i),Z(i),'.k','MarkerSize',20)
hold on
end
plot(W,Z,'-b')
xlabel('w','FontSize',25,'FontWeight','bold')
ylabel('b','FontSize',25,'FontWeight','bold')
set(gca,'FontSize',20)
grid on
更多回答(1 个)
Walter Roberson
2018-7-30
Stop closing your questions that people have already answered!!
We are not free private consultants: public questions and public answers are the price we "charges". We answer publicly as volunteers so that everyone can benefit. When you close questions after people have answered, then you are taking advantage of what you learned but you are grabbing it away to prevent anyone else from benefiting from the time and knowledge that other people have contributed.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!