fprintf 13 values in a 5x4 matrix without zeros.
Show older comments
I first change my data set from a matrix to vector using the reshape
A = reshape(OriginalA, numel(A),1)
B = reshape(OriginalB, numel(A),1)
then found the intersection
C=sextor(A,B); (13 by 1 vector)
turnC into a 5x4 matrix ncol=4 nrow=ceil(numel(C)/ncol); for i=1:nrows for i=1:ncol if j == nrows extran=nrows-round(numel(C)/ncol) for k=1:extran D(nrows,k)=C((i-1)*ncol+k); else D(i,j)=C(i-1)*ncol+j); end end end
Now I want to print it to a file where there are 4 or 8 columns because that was what a separate program wants.
d1, d2, d3, d4,
d5, d6, d7, d8,
d9, d10, d11, d12,
d13
Tried
for i=1:nrow
fprintf(fid,'%10i, %10i, %10i, %10,\n',D(i,1),D(i,2),D(i,3),D(i,4))
end
it gives me the zeros though and I don't want them.
Accepted Answer
More Answers (1)
Mark
on 15 Jul 2013
0 votes
Categories
Find more on Matrices and Arrays 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!