I want to make the K as function of time but how can I do I have no idea, the K should evolve as Y evolve.
Show older comments
ti = 0;
tf = 70E-8;
tspan=[ti tf];
k = 1E-3;
% I want to make this as the function of the time here, But how can I do
% this I don't have any idea, It's suppose to be like this that the as the
% Y elvolve with time same I want to do with K
h = 1E-2;
y0= [(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
(h)*rand(2,1); ((-3.14).*rand(1,1) + (3.14).*rand(1,1));
((-3.14).*rand(20,1) + (3.14).*rand(20,1))];
yita_mn = [
0 1 0 0 0 0 0 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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))));
L = (((Y(:,2) - mean(Y(:,2))).^2 + (Y(:,5) - mean(Y(:,5))).^2 + (Y(:,8) - mean(Y(:,8))).^2 + ...
(Y(:,11) - mean(Y(:,11))).^2 +(Y(:,14) - mean(Y(:,14))).^2 +(Y(:,17) - mean(Y(:,17))).^2+ ...
(Y(:,20) - mean(Y(:,20))).^2+(Y(:,23) - mean(Y(:,23))).^2 + (Y(:,26) - mean(Y(:,26))).^2 + ...
(Y(:,29) - mean(Y(:,29))).^2+(Y(:,32) - mean(Y(:,32))).^2 + (Y(:,35) - mean(Y(:,35))).^2 + ...
(Y(:,38) - mean(Y(:,38))).^2+(Y(:,41) - mean(Y(:,41))).^2 +(Y(:,44) - mean(Y(:,44))).^2 + (Y(:,47) - mean(Y(:,47))).^2+(Y(:,50) - mean(Y(:,50))).^2 +(Y(:,53) - mean(Y(:,53))).^2 + (Y(:,56) - mean(Y(:,56))).^2+(Y(:,59) - mean(Y(:,59))).^2)/19).^(0.5);
S1 = (Y(:,2) - mean(Y(:,2)))./mean(Y(:,2));
S2 = (Y(:,5) - mean(Y(:,5)))./mean(Y(:,5));
S3 = (Y(:,8) - mean(Y(:,8)))./mean(Y(:,8));
S4 = (Y(:,11) - mean(Y(:,11)))./mean(Y(:,11));
S5 = (Y(:,14) - mean(Y(:,14)))./mean(Y(:,14));
S6 = (Y(:,17) - mean(Y(:,17)))./mean(Y(:,17));
S7 = (Y(:,20) - mean(Y(:,20)))./mean(Y(:,20));
S8 = (Y(:,23) - mean(Y(:,23)))./mean(Y(:,23));
S9 = (Y(:,26) - mean(Y(:,26)))./mean(Y(:,26));
S10 = (Y(:,29) - mean(Y(:,29)))./mean(Y(:,29));
S11 = (Y(:,32) - mean(Y(:,32)))./mean(Y(:,32));
S12 = (Y(:,35) - mean(Y(:,35)))./mean(Y(:,35));
S13 = (Y(:,38) - mean(Y(:,38)))./mean(Y(:,38));
S14 = (Y(:,41) - mean(Y(:,41)))./mean(Y(:,41));
S15 = (Y(:,44) - mean(Y(:,44)))./mean(Y(:,44));
S16 = (Y(:,47) - mean(Y(:,47)))./mean(Y(:,47));
S17 = (Y(:,50) - mean(Y(:,50)))./mean(Y(:,50));
S18 = (Y(:,53) - mean(Y(:,53)))./mean(Y(:,53));
S19 = (Y(:,56) - mean(Y(:,56)))./mean(Y(:,56));
S20 = (Y(:,59) - mean(Y(:,59)))./mean(Y(:,59));
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]);
xlim([0 8E4]);
yticks(0:0.1:1);
function dy = rate_eq(t,y,yita_mn,N,o,k)
dy = zeros(4*N,1);
dGdt = zeros(N,1);
dAdt = zeros(N,1);
dOdt = zeros(N,1);
P = 0.20;
a = 1;
T = 2000;
tp = 1E-12;
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) + yita_mn(i,j)*(At(j))*cos(Ot(j)-Ot(i));
dOdt(i) = dOdt(i) + 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)) - (k).*(y(j2)./y(j5)).*sin(y(n61)) - (k).*(y( j5)./y(j2)).*sin(y(n61)) + (k).*(y(j8)./y(j5)).*sin(y(n62)) + (k).*(y(j59)./y(j2)).*sin(y(n80));
end
1 Comment
Alan Stevens
on 1 Jan 2023
You don't say in what way you want k to change with time.
Answers (0)
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!