Merging two arrays containing decimal points into a table
Show older comments
I am currently working on data stored in netCDF format.
Each variable was read into a variable (n x 1 array) using the ncread() function
Ex. var = ncread(FilePath, 'var')
These variables contain decimal points (Ex. -1.0874020).
Using these individual variables I have read in, I would like to construct a table.
Ex.
data = [var1 var2 var3];
colNames = {'var1', 'var2', 'var3'};
table= array2table(data, 'VariableNames', colNames);
However, when I join the variables together, (data = [var1 var2 var3];) for some reason the variables stored in 'data' turns into integers (Ex. -1).
How can I merge arrays containing decimal points into a table?
Thanks,
3 Comments
dpb
on 9 Jun 2022
Show us all the code in context and the result of
whos var* data
format short;format compact
head(table)
Unless the data are not numeric, any apparent loss of precision will simply be one of how the data are shown on screen; MATLAB will not have rounded nor truncated a double in the process of catenating variables; something else is confusing the picture here...but we don't have enough enough to know just what, not having the actual data nor precise code in entirety.
George Sato
on 9 Jun 2022
Accepted Answer
More Answers (0)
Categories
Find more on NetCDF 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!