fprintf 13 values in a 5x4 matrix without zeros.
Afficher commentaires plus anciens
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.
Réponse acceptée
Plus de réponses (1)
Mark
le 15 Juil 2013
0 votes
Catégories
En savoir plus sur Matrices and Arrays dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!