I have a 2d array of unknown size. I wish to write this into a file. After doing so i have similar arrays which have to be appended to the same file. This is one part. Other part is that I have to read the same file one array at a time. I don't know the size so the arrays have to separated. I wish to get the code for the same. The array contains only numeric data. I don't know what numbers are present in the file. Just there is an integer 2d array which has to be written to a file by a function separating more arrays as i store them in the file and another function which can read the same file one array at a time.
Can anyone help? Thanks

답변 (2개)

Paul
Paul 2013년 12월 13일
편집: Paul 2013년 12월 13일

0 개 추천

I would suggest saving each array inside an overall structure and then saving it.
for example
x=[1,2,3,4,5,6,7,8,9];
Y=[1,2];
Arrays.Data=x ;
Arrays.Data(1,2)=Y;

댓글 수: 1

Ravi Teja
Ravi Teja 2013년 12월 13일
Can u provide me with a function and code for the same?

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

Image Analyst
Image Analyst 2013년 12월 13일

0 개 추천

You can save the various arrays to a mat file with save(). You can recall them separately also. Pretty easy - just look up save() in the help.

댓글 수: 1

Ravi Teja
Ravi Teja 2013년 12월 13일
function A= write(M) edit text.txt; save('test.txt','M','-append');
This is what I have written but it's giving me an error
Unable to write file test.txt: No such file or directory.
Error in ==> write at 3 save('test.txt','M','-append');
M is a two d array.
How do i solve this?

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

카테고리

도움말 센터File Exchange에서 File Operations에 대해 자세히 알아보기

질문:

2013년 12월 13일

댓글:

2013년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by