From: neuroscienceneil on
I have the following code. I'm reading in data, mostly doubles, from a text file and trying to process it, however the last line of the code gives me all integers when I need to have decimal places for the doubles.

fid=fopen('TR11b.tsv');
index=textscan(fid,'%u %*s %*s %f64 %f64 %*s %u %u','headerlines',1);
fclose(fid);
newarrayvar=[];
left=[index{2}];
right=[index{3}];
newarrayvar=[index{1},left,right,index{5}];

Any ideas guys,

Thank you very much in advance :D

Neil.
From: Walter Roberson on
neuroscienceneil wrote:
> I have the following code. I'm reading in data, mostly doubles, from a
> text file and trying to process it, however the last line of the code
> gives me all integers when I need to have decimal places for the doubles.
>
> fid=fopen('TR11b.tsv');
> index=textscan(fid,'%u %*s %*s %f64 %f64 %*s %u %u','headerlines',1);
> fclose(fid);
> newarrayvar=[];
> left=[index{2}];
> right=[index{3}];
> newarrayvar=[index{1},left,right,index{5}];

newarrayvar = [double(index{1}),left,right,double(index{5})];

You are starting with an unsigned integer (because of the %u) and are
concatenating doubles on to that. When you do that, the result is going to be
unsigned integer -- the first data type in the concatenation has priority.