How to avoid empty brackets using textscan?
Show older comments
I am having trouble with the textscan function. I have a text file that contains only the information "Study Date: 8/30/2013 10:07:30 PM" (without the quotes). I am trying to use the textscan function to get the date and time information and put each number into a separate cell in an array. When I do this using the code below, for some reason it puts empty square brackets into each cell instead of the numbers. Please advise...
I am using this code to open my file and obtain the mm dd yy hh mm ss variables:
%%Startup clear data
clear all;
close all;
clc;
%%Find "event file" and get basic start time.
% Ask user to locate "date file"
[c,pathc] ...
= uigetfile({'C:\Users\HP\OneDrive\Documents\1 School Stuff\*.txt'} ...
, 'Select the Sandman Event List:');
% Send file info and open the file
file=[pathc c];
fid=fopen(file);
% Read basic date and time data about the file
% read the time for start of study
StudyDate ...
= textscan(file,'%*s %*s %d %d %d %d %d %d %*s',1,'delimiter',{':','/'});
fclose(fid);
Accepted Answer
More Answers (0)
Categories
Find more on Large Files and Big Data in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!