How to Save new data to existing structure data in a for loop without having to save the complete Matlab file from Zero?

조회 수: 10 (최근 30일)
Hi all,
I am really not sure how to ask this!
I have daily coming data in which i am doing evaluation and saveing the results in .mat file (data is in a mixed structure form). the size of the saved data is getting bigger with time, and loading and saving the data for each loop is taking time. yet the structure form is not changeing only the size of some fileds inside that structre. how can i save only the new data like apped or join or add to the existing .mat file.??
so my structure is as following:
Changing fields size in the loop
DayData.Ppos = [];
DayData.Qpos = [];
DayData.Upos = [];
....
Non-Changing fields size in the loop
DayData.CP = "xxxxxxxxx";
DayData.RawDataName = {'XXX1','XXX2','YYY1','YYY2'};
...
My Loop then look something like this:
for ii = 1:(DayFinished)
Connections = 5;
for i = 1:Connections
% Load available data for this connection
DayData = load(sprintf('MyMfile%d.mat',i)); % this will load the DayData for Connection i
% Do calculations
%Ppos = .....
%Qpos = .....
% Join Old data to new Data
DayData.Ppos = [DayData.Ppos,Ppos];
% and so on with the append or join
% now save the data
save(sprintf('MyMfile%d.mat',i),'DayData','-v7.3');
end
end
so you can see i am just simply joining new data to old data and saving the results for later use.
I already read about "matfile" function which seems to me the soluation i am looking for but i did not manage to make it work, so any help is of a great value thanks in advance
Best Regards

채택된 답변

Aubai
Aubai 2021년 7월 28일
So after looking i did not get any answer that can be cosidered.
I can till you it is not possible for the matfile function to read structure arrays the data need to be saved seperatly.
I hope this my help someone in the future

추가 답변 (1개)

J. Alex Lee
J. Alex Lee 2021년 6월 30일
I would consider using a database, a lightweight solution could be sqlite. I use the third party mksqlite for this purpose and it works quite well for me.

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by