필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

String plot of data read from text file

조회 수: 2 (최근 30일)
krs.rb1
krs.rb1 2012년 8월 8일
마감: MATLAB Answer Bot 2021년 8월 20일
I need to plot a graph of a certain value against date/time. Now i am getting values from a text file which are time stamped and i need to use those dates. So when I extract the required data its in form of string and i am not able to plot. Can anyone kindly help me out. Code is as follows :
clear;
clc;
%read data at start of program for calibration
io_contents = fullfile('Average Reflex Time.txt'); %File directory
filetext = fileread(io_contents); %Read contents of file
expr = '\A'; %extract data
fileread_info = regexp(filetext, expr, 'split');
file_info=regexprep(fileread_info,'Date :','');
file_info1=regexprep(fileread_info,'verage Reflex Time :','');
file_info1=regexprep(file_info1,'ms.','');
avg_ref_time =str2double(file_info1); %convert from cell to array
date = file_info{1}; %convert from cell to array????
plot(avg_ref_time,date); <---- cant plot : date is string
Text file data format :
Date : 8/8/2012 10:21:36 Average Reflex Time : 473.7ms.

답변 (1개)

Walter Roberson
Walter Roberson 2012년 8월 8일
datenum(date, 'mm/dd/yyyy hh:mm:ss') %adjust if dd is before mm

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by