Extracting data from a cell format

2 次查看(过去 30 天)
Lue
Lue 2011-3-29
I got some data from an equimpment and the data comes like a xls file. Nevertheless, smartly, the equipment output mixes strings and numbers in one single cell. So the result I get when I call one data from the array is '0.00064 uA DC'. Because each data mixes strings and numbers the listed format in my workspace for this data is CELL. I have to extract the number in each data and indetify the 'uA' part to convert it to e-6. So when a call the variable I have this data: m = '0.00064 uA DC' (cell) And I would like to convert this into: m = 6.4e-10 (number) Help?
Help?

回答(1 个)

Clemens
Clemens 2011-3-29
You can do the splitting with regexp.
It will look like:
out = regexp(in , '([.0-9]+) (.*)','tokens')
This will give you cells where in the first should only be numbers and in the second the unit.
str2double can convert the first part into a number.
The string for the unit you can pick apart similar.

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by