How to avoid empty brackets using textscan?
Mostrar comentarios más antiguos
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);
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Large Files and Big Data en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!