필터 지우기
필터 지우기

How do I use the solve function to solve the following equation

조회 수: 1 (최근 30일)
Poonam
Poonam 2013년 3월 17일
Here is my code. My aim is to solve for value beta using the following equations. I have used the solve function. But I get the following error The probem is that the equation fir beta is not being solved
Error using plot
Conversion to double from sym is not possible.
Error in proj (line 23)
plot(neff, lambda);
clc;
clear all;
close all;
lambda=1500;
nm=1e-9;
lambda=lambda*nm;
c=3e8;
w=c./lambda;
width=20: 20:100;
width=width.*nm
ev=1240*nm;
einf=3.7;
wp=9.7*ev;
gamma=.018*ev;
emw=einf-(wp.*wp)./(w.*(w+gamma.*i))
nd=1.46;
ed=nd*nd;
k0=2*pi./lambda;
syms beta
solve(emw.*sqrt(beta*beta-ed.*k0.*k0).*tanh(width.*sqrt(beta*beta-ed.*k0.*k0)./2)+ed.*sqrt(beta*beta-emw.*k0.*k0)==0)
neff = beta./ k0;
plot(w, real(neff));
I cant really figure out what I'm doing wrong. Thank you for the help.

답변 (1개)

Walter Roberson
Walter Roberson 2013년 3월 18일
You solve() but you do not assign the result to anything. Try
Beta = solve(emw.*sqrt(beta*beta-ed.*k0.*k0).*tanh(w.*sqrt(beta*beta-ed.*k0.*k0)./2)+ed.*sqrt(beta*beta-emw.*k0.*k0)==0, beta);
neff = Beta ./ k0;
  댓글 수: 4
Poonam
Poonam 2013년 3월 22일
Beta = [ empty sym ]
Poonam
Poonam 2013년 3월 22일
but when I plot the eqn emw.*sqrt(beta*beta-ed.*k0.*k0).*tanh(w.*sqrt(beta*beta-ed.*k0.*k0)./2 and -ed.*sqrt(beta*beta-emw.*k0.*k0) they intersect. So I do not know what I'm doing wrong with the solve
width=linspace(20,100,100);
length(width)
width=width.*nm;
beta= linspace(5e5,5e7,100);
for i1= 1:100
for i2= 1:100
a1(i1,i2)= -ed.*sqrt(beta(i2).*beta(i2)-emw.*k0.*k0);
a2(i1,i2)=emw.*sqrt(beta(i2).*beta(i2)-ed.*k0.*k0).*tanh(width(i1).*sqrt(beta(i2).*beta(i2)-ed.*k0.*k0)./2);
end
end
mesh(beta,width,real(a1));
hold on;
mesh(beta,width,real(a2));
xlabel('beta');
ylabel('w');
zlabel('eqn');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by