Saving data after each iteration
이전 댓글 표시
Hello so I'm trying something a bit different then before, so my code is as follows:
all_pulse = [ ];
files = importdata('name_files2.txt');
for i = 1:length(files)
[C_pulse, D_pulse] = One_Person(files{i}); %this is a pre-defined function
save('all_pulse', 'C_pulse', 'D_pulse') %what I have so far
end
The only thing I am having trouble with is that I want to save the outputs of my function (C_pulse and D_pulse) into the matrix all_pulse after each iteration of the loop so that I have all the data I need from each file in the larger matrix. Not sure how to do this. Thanks,
댓글 수: 3
dpb
2021년 6월 22일
See the doc for save -- there is an 'append' flag, but it won't work the way you intend because you can't have multiple copies of the same variable in a .mat file. And, even if you could or change the name, it's got the same performance hangup up that the non-allocated catenation operation has--although not to quite the same extent I think since it can move the file pointer to the end via the OS i/o routines without having to read the whole file into memory every time.
This likely is a good place for cell arrays for the quick 'n dirty solution.
Mathieu NOE
2021년 6월 23일
hello
what size have C_pulse, D_pulse ?
Sydney Kehoe
2021년 6월 23일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Array Geometries and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!