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일)
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