Double becomes int32 --why??

11 vues (au cours des 30 derniers jours)
ANJ
ANJ le 18 Juin 2012
My goal is to write a file that has a column of double precision numbers for each subject. Here's what I have:
TadvDiff(1,qq) = currsubj; %Heading that displays subject ID number
TadvDiff(2:(timepoints+1),qq) = TminusC;
currsubj and TminusC are both double-precision. Somehow, TadvDiff is int32.
After looping through each subject, I write TadvDiff to a file:
dlmwrite('TadvDiffN108.txt',TadvDiff,'delimiter','\t','precision', '%.4f');
which ends up being all 1s and 0s when I need decimals. Why did my doubles become ints, and how can I correct this?
Thanks!
  5 commentaires
Walter Roberson
Walter Roberson le 18 Juin 2012
Somehow, the very first time you write into TadvDiff, you must be storing int32. That very first write determines the datatype after that.
Can you reasonably pre-allocate your TadvDiff array? e.g.,
TadvDiff = zeros(timepoints+1, 17);
ANJ
ANJ le 18 Juin 2012
Great, that did the trick! Thanks so much!

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by