如果我有下图中红线所有点的坐标, 那么如何在matlab中编写代码来使用这些坐标绘制如下图所示的行?
我的意思是因为一条线来自上轴,例如可以将坐标放在矩阵中,然后绘制它吗?对于所有线都来自左轴的情况,我可以使用矩阵绘制它们。
看看这个
clc; clear;
format long e
s=0;
lmin=0.8; lmax=2.5;
bmin=1.0; bmax=1.5;
lam=linspace(lmin,lmax,100);
for n=1:length(lam)
increm*emphasized text*ent=0.0001; tolerence=1e-14; xstart=bmax-increment;
x=xstart;
dx=increment;
m=0;
while x > bmin
while dx/x >= tolerence
if sign(fTE(lam(n),x,s))*sign(fTE(lam(n),x-dx,s))<0
dx=dx/2;
else
x=x-dx;
end
end
if abs(fTE(lam(n),x,s)) < 1e-2
m=m+1;
if n>1 && m==1 && (x-max(r(1,:))) > 1e-4
b=zeros(1,n-1);
r=[b;r];
end
r(m,n)=x;
end
dx=increment;
x=0.999*x;
end
end
switch s
case 0
figure
hold on,plot(lam,r(1,:),'b')
text(1.6,1.98,'TE(0)','FontSize',10),
hold on,plot(lam,r(2,:),'c')
text(1.8,1.89,'TE(2)','FontSize',10),
xlim([lmin,lmax]);ylim([bmin,bmax]),
xlabel('\lambda(\mum)'),ylabel('\beta-bar')
case 1
figure
hold on,plot(lam,r(1,:),'m')
%text(1.4,1.9,'TE(1)','FontSize',10),
hold on,plot(lam,r(2,:),'r')
%text(1.37,1.54,'TE(3)','FontSize',10),
xlim([lmin,lmax]);ylim([bmin,bmax]),
xlabel('\lambda(\mum)'),ylabel('\beta-bar')
end
和fTE是:
function y=fTE(lambda,betab,s)
n1=2; n2=1.5; n3=1;
z0=120*pi;
d1=1; d2=1; d3=1; a=1;
k0=2*pi/lambda;
ub= sqrt(n1^2-betab^2);
vb= sqrt(n2^2-betab^2);
w= sqrt(betab^2-n3^2);
Ub=k0*ub*d1;
Vb=k0*vb*d2;
W=k0*w*d3;
z1=z0/ub; z1b=z1/z0;
a0b=tan(Vb)/(w*ub)+tan(Ub)/(vb*w)-tanh(W)/(vb*ub)-tan(Vb)*tanh(W)*tan(Ub)/w^2;
b0b=tan(Vb)*tan(Ub)/(vb^2*w)-tan(Vb)*tanh(W)/(vb^2*ub)+tanh(W)*tan(Ub)/(vb*w^2)- tan(Vb)*tan(Ub)/(w*ub^2)-tan(Vb)*tanh(W)/(w^2*ub)+tanh(W)*tan(Ub)/(vb*ub^2);
c0b=tan(Ub)/(vb*w*ub^2)+tanh(W)/(vb*w^2*ub)+tan(Vb)*tanh(W)*tan(Ub)/(vb^2*ub^2)+tan(Vb)/(vb^2*w*ub);
U0= k0*ub*a; m=s;
y=(a0b*z1b^2+c0b)+(a0b*z1b^2-c0b)...
*cos(2*U0+m*pi)-b0b*z1b*sin(2*U0+m*pi);
end
答案 0 :(得分:2)
也许我误解了,但你可以在这样的情节中绘制多条线:
>> x = 1:0.2:3;
>> y = sin(x);
>> y2 = cos(x);
>> [x; y; y2]
ans =
Columns 1 through 9
1.0000 1.2000 1.4000 1.6000 1.8000 2.0000 2.2000 2.4000 2.6000
0.8415 0.9320 0.9854 0.9996 0.9738 0.9093 0.8085 0.6755 0.5155
0.5403 0.3624 0.1700 -0.0292 -0.2272 -0.4161 -0.5885 -0.7374 -0.8569
Columns 10 through 11
2.8000 3.0000
0.3350 0.1411
-0.9422 -0.9900
>> plot(x,y)
>> hold on
>> plot(x,y2)