I want to write my 3D data in separate text files, my data matrix has dimensions = 8x256x32. I want to write 8 separate files, all having 256x32 data values. how can I do this? Kindly help me with the following code:
[a,b,c]=size(sig);
for x = 1:8
filename = ['signal' num2str(x) '.txt'];
for y = 1:256
for z = 1:32
dlmwrite(filename,sig(x,:,:),'delimiter','\t')
end
end
fclose(filename);
end
thank you.

댓글 수: 5

KSSV
KSSV 2017년 10월 18일
When you write this matrix 256X32, data will be disturbed from 8X256 matrix.....is it okay?
Stephen23
Stephen23 2017년 10월 18일
편집: Stephen23 2017년 10월 18일
You provide a 3D array to dlmwrite, with size 1x256x32. You need to provide a matrix.
Nabigha Nazneen
Nabigha Nazneen 2017년 10월 18일
@KSSV, I want to write 8 separate files of 256x32 data matrix. @Stephen Cobeldick, how can I pass a matrix when I have 3D data, do I need to squeeze the data first and later write the file?
KSSV
KSSV 2017년 10월 18일
I suggest you to write whole data 8x256x32 into single file......there are formats which support this.
Nabigha Nazneen
Nabigha Nazneen 2017년 10월 18일
I need these file to be ported to visual C, I need them as this. I don't need single file. thanks for assistance

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

답변 (1개)

Jan
Jan 2017년 10월 18일
편집: Jan 2017년 10월 18일

0 개 추천

You are talking about 65536 numbers. Text files are useful, if they are read or edited by a human, but nobody will read and understand such a pile of values.
Therefore it would be easier, faster and cleaner to store the values in a binary format using fwrite. This will allow for an easier method to import the data later on also.

댓글 수: 1

Nabigha Nazneen
Nabigha Nazneen 2017년 10월 18일
okay, I try writing text files for later use.

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

카테고리

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

질문:

2017년 10월 17일

댓글:

2017년 10월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by