How can I resolve this issue here, can anyone please help.
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
% 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) +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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
0 commentaires
Réponses (1)
Torsten
le 19 Jan 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.
Voir également
Catégories
En savoir plus sur Ordinary Differential Equations dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!