Vectors must be the same length

1 vue (au cours des 30 derniers jours)
mohammad heydari
mohammad heydari le 13 Mar 2020
Hi
I want to draw a diagram but I get an error. I understand the concept of error but I have no idea how to make the vectors equal.
Please guide me.
main:
clc
clear all
tspan = [0 5e-9]; % time interval, up to 2 ns
y0 = [0.2,0.2,0.2];
[t,y] = ode45(@rate_fano1,tspan,y0);
size(t);
t=t*1e9;
y = abs(y); % Change As Necessary To Get The Desired Resull
params % input of needed parameters
pt=2.*epsilon0.*ref_index.*c.*(abs(y(:,2)+p.*y(:,3))).*2;
pc=2.*epsilon0.*ref_index.*c./(gamma_p./gamma_c).*(abs(y(:,3))).*2;
figure(1)
plot(t, pt, t, pc,'.-'); % divided to normalize
xlabel('time [ns]','FontSize',14); % size of x label
ylabel('Arbitrary units','FontSize',14); % size of y label
set(gca,'FontSize',14); % size of tick marks on both axis
legend('pt','pc', 'Location','SE') % legend inside the plot); % divided to normalize
x=[0 deltac/gamma_T];
figure(2)
plot(x, pt); % divided to normalize
xlabel('time [ns]','FontSize',14); % size of x label
ylabel('Arbitrary units','FontSize',14); % size of y label
set(gca,'FontSize',14); % size of tick marks on both axis
legend('pt','pc', 'Location','SE') % legend inside the plot
figure(3)
plot(t, y(:,1)./N_0); % divided to normalize
xlabel('time [ns]','FontSize',14); % size of x label
ylabel('Arbitrary units','FontSize',14); % size of y label
set(gca,'FontSize',14); % size of tick marks on both axis
legend('N', 'Location','SE') % legend inside the plot); % divided to normalize
figure(4)
plot(t, y(:,2)); % divided to normalize
xlabel('time [ns]','FontSize',14); % size of x label
ylabel('Arbitrary units','FontSize',14); % size of y label
set(gca,'FontSize',14); % size of tick marks on both axis
legend('A+', 'Location','SE') % legend inside the plot); % divided to normalize
figure(5)
plot(t, y(:,3)); % divided to normalize
xlabel('time [ns]','FontSize',14); % size of x label
ylabel('Arbitrary units','FontSize',14); % size of y label
set(gca,'FontSize',14); % size of tick marks on both axis
legend('A-', 'Location','SE') % legend inside the plot); % divided to normalize
function:
function yx = rate_fano1(t,y)
params % input of needed parameters
r_R=(-p*gamma_c)/(1i*(deltac)+gamma_T);
sigmaa=((2.*epsilon0.*ref_index.*ref_indexg)./(hbar.*w_s)).*(1+(abs(r_R))).*(1+(abs(r_R)))./(conf.*g_n.*(y(1)-N_0))
yx=zeros(3,1);
yx(1)=I./(e.*V_a)-y(1)./tau1-(V_g.*g_n.*(y(1)-N_0).*sigmaa.*(abs(y(2)))^2)./V_m;
yx(2)=1/2*(1-1i*henry).*conf.*V_g.*g_n.*(y(1)-N_ss).*y(2)+gamma_L.*((y(3)./(r_R)-y(2)));
yx(3)=(-1i.*deltac-gamma_T).*y(3)-p.*gamma_c.*y(2);
parameters:
c = 2.99792458e8; % velocity of light [cm/s]
e = 1.6021766208e-19; % elementary charge [C]
h = 6.626068e-34; % Planck constant [J s]
h_eV = h/e;
hbar = h/(2*pi); % Dirac constant [J s]
hbar_ev = hbar/e;
p=-1;
L = 5e-6; % cavity length [um];
A = 0.21e-12;
conf = 0.5; % confinement factor [dimensionless]
conf_NC =0.3; % Nanocavity confinement factor [dimensionless]
V_a=A*L;
V_m = V_a/conf; % cavity volume [cm^3]
V_NC=0.24e-18;
ref_index = 3.5; % effective mode index
ref_indexg=3.5; % Group refractive index
V_g = c/ref_index; % group velocity [cm/s]
tau1 = 0.5e-9; % Waveguide carrier lifetime and Nanocavity carrier lifetime [s]
g_n = 5e-21;
N_0=1e24;
N_ss=1e24;
I =5e-3;
henry_i=1000; %Internal loss factor[cm^-1] (alphai)
henry = 1; %Linewidth enhancement factor (alpha)
Qt = 500;
Qi = 14300;
Qp = 10000;
lambda0 = 1554e-9;
deltalambda = 0.01e-9;
lambda_start = 1540e-9;
lambda_end = 1560e-9;
lambda = lambda_start:deltalambda:lambda_end;
omega = 2*pi*c./lambda;
omega0 = omega(find(lambda==lambda0));
gamma_i = omega0/(2*Qi);
gamma_p = omega0/(2*Qp);
gamma_T = omega0/(2*Qt);
gamma_c = gamma_T-gamma_i-gamma_p;
gamma_L=V_g/(2*L);
rB = 0.2 ;
tB = sqrt(1-rB^2);
w_r=omega0;
w_s=1.2121*10^15;
w_c=1.2125*10^15;
epsilon0 = 8.854187817e-12; % free space permittivity[F.cm^-1]
rho=(2*epsilon0*ref_index*c)./gamma_c.*hbar_ev.*w_r; %normalisation factor
r_L=1; % Left mirror re?ectivity
deltac=1.2125*10^15-1.2121*10^15;
  3 commentaires
Guillaume
Guillaume le 13 Mar 2020
"want to enlarge the range of numbers"... of which variable?
In any case, if you create a vector of numbers from 0 to n but instead want a vector of numbers from -2 to 10 then the answer is going to be: create the vector from -2 to 10 instead of 0 to n. Presumably, that's not what you're asking so you need to give more details.
mohammad heydari
mohammad heydari le 13 Mar 2020
In fact, the horizontal axis range I expect:
Please refer to the attachment(The desired chart)
And what I have:

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Contour Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by