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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by