Quantcast
Channel: Active questions tagged units - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 41

Importing scientific data with uncertainties and units

$
0
0

I want to import scientific data from a CSV file. The data are length measurements in centimeters with uncertainties. I want to import the data with uncertainties and units into a vector - please see the code below. I can do this without units, but I am stuck how to do this with units for the whole data set. Any help is appreciated!Thanks!

Remove["Global`*"];data=Import["data.csv","CSV", "HeaderLines"->2];TableForm[{Transpose[data]}, TableHeadings->{None,{"x (cm)","dx(cm)"}}]

enter image description here

x=VectorAround[data[[All,1]],data[[All,2]]]

enter image description here

I want to add units (cm) to variable x. I want it to beVectorAround[{49.9 cm, 60.2 cm, 70.1 cm, 79.8 cm , 90. cm, 100.2 cm }, {0.1 cm, 0.1 cm, 0.1 cm, 0.1 cm, 0.2 cm, 0.2 cm}].

For example, I can do this manually for two data points:

x=VectorAround[{Quantity[data[[All,1]][[1]],"Centimeters"],Quantity[data[[All,1]][[2]],"Centimeters"]},{Quantity[data[[All,2]][[1]],"Centimeters"],Quantity[data[[All,2]][[2]],"Centimeters"]}]

enter image description here

Is there a better way to do this? This would be highly impractical to do manually with a large data set.


Viewing all articles
Browse latest Browse all 41

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>