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

3 Ansichten (letzte 30 Tage)
Poonam
Poonam am 17 Mär. 2013
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.

Antworten (1)

Walter Roberson
Walter Roberson am 18 Mär. 2013
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 Kommentare
Poonam
Poonam am 22 Mär. 2013
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');

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by