How can I resolve this issue here, can anyone please help.

1 visualización (últimos 30 días)
SAHIL SAHOO
SAHIL SAHOO el 19 de En. de 2023
Comentada: Torsten el 19 de En. de 2023
% ti = 0;
% tf = 70E-5;
tp = 1E-9;
tspan= [0:1E-8:7E-5]./tp;
k = 1E-6;
k1 = k.*(tspan);
h = 1E-2;
h1 = 1;
y0= [(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
h1*((-3.14).*rand(20,1) + (3.14).*rand(20,1));
];
yita_mn = [
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1;
1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1;
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
];
N = 20;
o = sort(10e2*rand(1,20),'ascend');
[T,Y]= ode45(@(t,y) rate_eq(t,y,yita_mn,N,o,k1),tspan,y0);
Unable to perform assignment because the left and right sides have a different number of elements.

Error in solution>rate_eq (line 91)
dAdt(i) = dAdt(i) + k1.*yita_mn(i,j).*(At(j))*cos(Ot(j)-Ot(i));

Error in solution (line 55)
[T,Y]= ode45(@(t,y) rate_eq(t,y,yita_mn,N,o,k1),tspan,y0);

Error in odearguments (line 92)
f0 = ode(t0,y0,args{:}); % ODE15I sets args{1} to yp0.

Error in ode45 (line 107)
odearguments(odeIsFuncHandle,odeTreatAsMFile, solver_name, ode, tspan, y0, options, varargin);
r = ((1/20).*( exp(i.*Y(:,3)) + exp(i.*Y(:,6)) + exp(i.*Y(:,9)) + exp(i.*Y(:,12)) + exp(i.*Y(:,15)) ...
+exp(i.*Y(:,18)) +exp(i.*Y(:,21)) +exp(i.*Y(:,24)) + exp(i.*Y(:,27)) + exp(i.*Y(:,30)) + exp(i.*Y(:,33)) ...
+ exp(i.*Y(:,36)) + exp(i.*Y(:,39)) +exp(i.*Y(:,42)) + exp(i.*Y(:,45)) + exp(i.*Y(:,48)) + exp(i.*Y(:,51)) + exp(i.*Y(:,54))+ exp(i.*Y(:,57)) + exp(i.*Y(:,60))));
figure(1)
plot(T,abs(r),'linewidth',1.5)
xlabel("Time(in units of t_{p})")
ylabel("Order parameter")
grid on
set(gca,'fontname','times New Roman','fontsize',18,'linewidth',1.8);
ylim([0 1.2]);
% xlim([0 6E4]);
% yticks(0:0.1:1);
function dy = rate_eq(t,y,yita_mn,N,o,k1)
dy = zeros(4*N,1);
dGdt = zeros(N,1);
dAdt = zeros(N,1);
dOdt = zeros(N,1);
P = 0.05;
a = 0;
T = 2000;
tp = 1E-9;
Gt = y(1:3:3*N-2);
At = y(2:3:3*N-1);
Ot = y(3:3:3*N-0);
for i = 1:N
dGdt(i) = (P - Gt(i) - (1 + 2.*Gt(i)).*((At(i)))^2)./T ;
dAdt(i) = Gt(i)*(At(i));
dOdt(i) = -a.*Gt(i) + o(1,i).*tp;
for j = 1:N
dAdt(i) = dAdt(i) + k1.*yita_mn(i,j).*(At(j))*cos(Ot(j)-Ot(i));
dOdt(i) = dOdt(i) + k1.*yita_mn(i,j).*((At(j)/At(i)))*sin(Ot(j)-Ot(i));
end
end
dy(1:3:3*N-2) = dGdt;
dy(2:3:3*N-1) = dAdt;
dy(3:3:3*N-0) = dOdt;
n1 = (1:20)';
n2 = circshift(n1,-1);
n61 = n1 +60;
n62 = circshift(n61,-1);
n80 = circshift(n61,1);
j2 = 3*(1:20)-1;
j5 = circshift(j2,-1);
j8 = circshift(j2,-2);
j59 = circshift(j2,1);
dy(n61) = (o(1,n2).' - o(1,n1).').*tp - a.*(Gt(n2) - Gt(n1)) - (k1).*(y(j2)./y(j5)).*sin(y(n61)) - (k1).*(y( j5)./y(j2)).*sin(y(n61)) + (k1).*(y(j8)./y(j5)).*sin(y(n62)) + (k1).*(y(j59)./y(j2)).*sin(y(n80));
end

Respuestas (1)

Torsten
Torsten el 19 de En. de 2023
k1 is a vector. Thus with the commands
dAdt(i) = dAdt(i) + k1.*yita_mn(i,j).*(At(j))*cos(Ot(j)-Ot(i));
dOdt(i) = dOdt(i) + k1.*yita_mn(i,j).*((At(j)/At(i)))*sin(Ot(j)-Ot(i));
you want to assign a vector (right hand side) to a scalar (left hand side).
Not possible.
  4 comentarios
SAHIL SAHOO
SAHIL SAHOO el 19 de En. de 2023
Editada: SAHIL SAHOO el 19 de En. de 2023
Thank you so much for your help and heree I want to plot the variation of k1 with T how can I do that ?
% ti = 0;
% tf = 70E-5;
tp = 1E-9;
tspan= [0:1E-8:7E-5]./tp;
h = 1E-2;
h1 = 1;
y0= [(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); h1*((-3.14).*rand(1,1) + (3.14).*rand(1,1));
h1*((-3.14).*rand(20,1) + (3.14).*rand(20,1));
];
yita_mn = [
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1;
1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 0;
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1;
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0
];
N = 20;
o = sort(10e2*rand(1,20),'ascend');
[T,Y]= ode45(@(t,y) rate_eq(t,y,yita_mn,N,o),tspan,y0);
r = ((1/20).*( exp(i.*Y(:,3)) + exp(i.*Y(:,6)) + exp(i.*Y(:,9)) + exp(i.*Y(:,12)) + exp(i.*Y(:,15)) ...
+exp(i.*Y(:,18)) +exp(i.*Y(:,21)) +exp(i.*Y(:,24)) + exp(i.*Y(:,27)) + exp(i.*Y(:,30)) + exp(i.*Y(:,33)) ...
+ exp(i.*Y(:,36)) + exp(i.*Y(:,39)) +exp(i.*Y(:,42)) + exp(i.*Y(:,45)) + exp(i.*Y(:,48)) + exp(i.*Y(:,51)) + exp(i.*Y(:,54))+ exp(i.*Y(:,57)) + exp(i.*Y(:,60))));
% figure(1)
% plot(T,abs(r),'linewidth',1.5)
% xlabel("x")
% ylabel("y")
% grid on
% set(gca,'fontname','times New Roman','fontsize',18,'linewidth',1.8);
% ylim([0 1.2]);
% xlim([0 6E4]);
% yticks(0:0.1:1);
figure(2)
plot(k1,T)
Unrecognized function or variable 'k1'.
function dy = rate_eq(t,y,yita_mn,N,o)
k = 1e-6;
k1 = min(k*t,4);
dy = zeros(4*N,1);
dGdt = zeros(N,1);
dAdt = zeros(N,1);
dOdt = zeros(N,1);
P = 0.05;
a = 0;
T = 2000;
tp = 1E-9;
Gt = y(1:3:3*N-2);
At = y(2:3:3*N-1);
Ot = y(3:3:3*N-0);
for i = 1:N
dGdt(i) = (P - Gt(i) - (1 + 2.*Gt(i)).*((At(i)))^2)./T ;
dAdt(i) = Gt(i)*(At(i));
dOdt(i) = -a.*Gt(i) + o(1,i).*tp;
for j = 1:N
dAdt(i) = dAdt(i) + k1.*yita_mn(i,j).*(At(j))*cos(Ot(j)-Ot(i));
dOdt(i) = dOdt(i) + k1.*yita_mn(i,j).*((At(j)/At(i)))*sin(Ot(j)-Ot(i));
end
end
dy(1:3:3*N-2) = dGdt;
dy(2:3:3*N-1) = dAdt;
dy(3:3:3*N-0) = dOdt;
n1 = (1:20)';
n2 = circshift(n1,-1);
n61 = n1 +60;
n62 = circshift(n61,-1);
n80 = circshift(n61,1);
j2 = 3*(1:20)-1;
j5 = circshift(j2,-1);
j8 = circshift(j2,-2);
j59 = circshift(j2,1);
dy(n61) = (o(1,n2).' - o(1,n1).').*tp - a.*(Gt(n2) - Gt(n1)) - (k1).*(y(j2)./y(j5)).*sin(y(n61)) - (k1).*(y( j5)./y(j2)).*sin(y(n61)) + (k1).*(y(j8)./y(j5)).*sin(y(n62)) + (k1).*(y(j59)./y(j2)).*sin(y(n80));
end
Torsten
Torsten el 19 de En. de 2023
k = 1e-6;
k1 = min(k*T,4);
plot(k1,T)

Iniciar sesión para comentar.

Categorías

Más información sobre Ordinary Differential Equations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by