Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I save 'H' using Runge-Kutta time-step in a single . mat file each day while the code will be running for six days?

1 回表示 (過去 30 日間)
Kayode Odeyemi
Kayode Odeyemi 2020 年 6 月 3 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
dt=90; % 90 seconds
tend=1:6;% for six days
time = zeros ((3600/dt)*24*tend,1);
%Runge-Kutta time step
for nt=1:tend*24*3600/dt
K = H;
d1 = dt*Chs(K,A,B,C,D);
K = H + 0.5*d1;
d2 = dt*Chs(K,A,B,C,D);
K = H + 0.5*d2;
d3 = dt*Chs(K,A,B,C,D);
K = H + d3;
d4 = dt*Chs(K,A,B,C,D);
H = H + 1/6*(d1 + 2*d2 + 2*d3 + d4);
time(nt,1) =(nt*dt)/(3600*24);
I need help on how to save H each day in single .mat file for six days while the code is running.

回答 (1 件)

KALYAN ACHARJYA
KALYAN ACHARJYA 2020 年 6 月 3 日
編集済み: KALYAN ACHARJYA 2020 年 6 月 3 日
Alert: I have no experience running code for six days. I also do not know the system requirements for this work. But here, based on my theoretical concept. You can stop the running execution anytime by CLTR+C. Please note I just tried to implement e the idea (ignoring the time of execution of instructions).
time=518400; %Total seconds in 6 days
dt=90;
tic
k=1;n=1;
while toc>time
%code
H(n)=
time_day=toc;
if time_day>=k*86400 %One day seconds
save(['Day' num2str(k) '.mat'],'H')
k=k+1;
n=0;
end
n=n+1;
pause(90);
end
  1 件のコメント
Kayode Odeyemi
Kayode Odeyemi 2020 年 6 月 7 日
編集済み: Kayode Odeyemi 2020 年 6 月 7 日
Thanks, but it doesn't work well.
time=518400; %Total seconds in 6 days
dt=90;
tic
k=1;n=1;
while toc>time
%code
H(n)= ?? %Not clear
time_day=toc;
if time_day>=k*86400 %One day seconds
save(['Day' num2str(k) '.mat'],'H')
k=k+1;
n=0;
end
n=n+1;
pause(90);
end

Community Treasure Hunt

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

Start Hunting!

Translated by