From: neuroscienceneil on 19 May 2010 13:59 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 19 May 2010 14:48 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.
|
Pages: 1 Prev: Sending data without the Data Acquisition Toolkit Next: Interp1 function |