Append rows to .mat file

조회 수: 68 (최근 30일)
Collegue
Collegue 2019년 9월 11일
댓글: Felix Lupp 2023년 12월 12일
Hello, I have a folder for example file_1 . I want to create a data.mat with the files that I have in file_1. Each time I add data to file_1 I would like to update the .data.mat and add the data in the next row of data.mat. How can I do it?
dataNew = data;
save(fullfile(mat_path ,'data'),'data');
  댓글 수: 1
Raj
Raj 2019년 9월 12일
"I want to create a data.mat with the files that I have in file_1" - What type of files?
"Each time I add data to file_1 " - In what way? Are you appending the existing file or adding new file?

댓글을 달려면 로그인하십시오.

채택된 답변

Jyothis Gireesh
Jyothis Gireesh 2019년 9월 16일
I understand that you want to add the files present in the folder ‘file_1’ into a single “. mat file. You may use the following functions to achieve the desired result.
  • save() - You may use the ‘-append’ attribute in save() to add the new data in the end of an existing .mat file. It may be better to ensure that the new variables do not have the same names as the existing variables. This may prevent overwriting the existing variables and subsequent loss of information.
  • matfile() - If there is constraint on the memory usage you may use this function instead. This function allows us to change the contents of .mat file without loading into memory. You may make use of the ‘Writable’ attribute to iswritable to enable write access. The new variables will be appended to the exisitng .mat file
You may go through the following documentation links if you need any clarification on the same.

추가 답변 (1개)

per isakson
per isakson 2019년 9월 14일
  댓글 수: 2
blues
blues 2019년 10월 23일
Hi,
I have 4 variables in the following format: (x, y, z, value). I would like to write a .mat file so that I can have
(0, 0, 0, 0.1); % I can write this by using (save test.mat x y z value)
(0, 0,1, 0.2); % how to add these lines without overwriting previous values?
(0, 1, 0, 0.3);
....................
How can I write this kind of .mat file? Any help would be hugely appreciated.
Felix Lupp
Felix Lupp 2023년 12월 12일

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by