Clear Filters
Clear Filters

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

1 view (last 30 days)
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.

Answers (1)

Walter Roberson
Walter Roberson on 18 Mar 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 Comments
Poonam
Poonam on 22 Mar 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');

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!