我正在使用ODE,我希望将BufferedReader tncReader = new BufferedReader(new FileReader("something.txt"));
BufferedWriter tncWriter = new BufferedWriter(new FileWriter("something_cleaned.txt"));
boolean allNull = true;
while(tncReader.readLine() != null ){
String s = tncReader.readLine();
String[] currentLine = s.split(";");
System.out.println(currentLine[0]);
for(String ss:currentLine){
if(ss!=null){
allNull = false;
tncWriter.write(s + System.getProperty("line.separator"));
break;
}
}
}
和rk(x, times1, func1, parms)
交替(更新)状态变量20次,因此每次新运行都以上一次运行的结果开始。提前谢谢!
rk(x, times2, func2, parms)
答案 0 :(得分:0)
这是我的快速解决方案,不是优雅,而是工作:
out_list <- list()
combined <- matrix(data = c(0,0,0,0), ncol = 4)
time_sum <- 0
for(i in seq(1,20,2)){
out1 <- rk(x, times1, func1, parms)
out_list[[i]] <- out1
x <- out1[200,2:4]
## sum up timeline
time_sum <- c(time_sum, time_sum[length(time_sum)]+out1[,"time"])
out2 <- rk(x, times2, func2, parms)
out_list[[i+1]] <- out2
x <- out2[200,2:4]
## sum up timeline
time_sum <- c(time_sum, time_sum[length(time_sum)]+out2[,"time"])
## combine both ODEs
combined <- rbind(combined, rbind(out1, out2))
}
## remove first column and "time" from combined matrix
combined <- combined[-1,]
time_sum <- time_sum[-1]
## plot ----
matplot(time_sum,combined[,2:4], type = "l")
的问候,
J_F