How to print a large 4D array into a csv or excel file
6 views (last 30 days)
Show older comments
Hi
Here are my attempts in printing a 4D array (i.e. an array with four coordinates):
1)Fixing the first two coordinates and printing the corresponding matrix:
A4d1=zeros(50,33);
offset=1;
for x=1:50
for y=1:50
for z=1:50
for k=1:33
A4d1(z,k)=DTI(x,y,z,k);
end
end
xlswrite('DTIvalues1.xls', A4d1, 1, sprintf('A4d1%d',offset));
%# increment offset
offset = offset + size(A4d1,1);
end
end
However, a)it was too large for an excel file. Mainly because I don't know how to use the sprintf and offset. So there were huge space gaps with no entries at all.
Also, how to add a title for each matrix, so that I know to which coordinate (x,y) it corresponds to? For example, having on the top row (x,y)=(4,5) and corresponding Matrix contents starting from the row below it.
2)Also, I am thinking of going entry by entry by skipping to next column and row manually via some matlab command. Just out of curiosity, how to skip to next row and column, eg. in C++ we use ',' and '\n' respectively.
This would require alot of redundant accounting, which is already taken care of by approach 1.
Thanks
0 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Data Import from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!