フィルターのクリア

Read only numerical value or seperate data using deliminater

4 ビュー (過去 30 日間)
Vijay Vythilingum
Vijay Vythilingum 2020 年 1 月 20 日
コメント済み: Vijay Vythilingum 2020 年 1 月 21 日
I have a data file with data, shown below. I would only like to read the time and Resistance value (around 606 in data), and put his into a matrix. Is there any way I can separate the data by a ' ' or '|' deliminater or just read the time and resistance value
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|605.62}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|605.62}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}
2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}

採用された回答

Allen
Allen 2020 年 1 月 20 日
Assuming that you ultimately want to extract the date/time and resistance values, and assign them to separate variables, the following should work. I am also making the assumption that your data is a cell-array of strings or character vectors.
C = {'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|605.62}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.21}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|605.62}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|607.40}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'
'2020-01-20 12:56:42: {TIMEPLOT|DATA|Resistance|T|606.81}'};
% Extracts the date and time portion of the character vectors and convert them to a datetime class.
Time = cellfun(@datetime,regexp(C,'(.*)(?=:)','match'));
% Time = regexp(C,'(.*)(?=:)','match'); % This will leave them as a cell-array of character vectors.
% Extracts the resistance values and convert them to a double class.
R = cellfun(@str2double,regexp(C,'(?,=.*|)(\d+\.\d+)','match'));
% R = regexp(C,'(?,=.*|)(\d+\.\d+)','match'); % This will leave them as a cell-array of character vectors

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCell Arrays についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by