I'm trying to write a script that allows the user to select a specific text file. Once the user selects the file, the script then opens it, reads it, and reads in the headers of the columns of the text file using textread, storing the headers. I'm having problems opening the file. The file returns -1, which means it wasn't opened, which is resulting in errors in textread. Here is the code I have been using below, along with error messages. I would appreciate help on this. Thank you.
[fileName1 pathName1]= uigetfile('~/*_gyro_out_Z.txt','Select the appropriate test file under *_gyro_out_Z.txt'); filepath=fullfile('pathName1','fileName1'); fid = fopen(filepath); [TimeHdr DriftELHdr DriftXELHdr DriftLOSHdr] = textread('fid', '%s %f %f %f'); DriftEL = char(DriftELHdr); DriftXEL = char(DriftXELHdr); DriftLOS = char(DriftLOSHdr);Error messages include:Error using textread (line 166)File not found.Error in multi_panel_plot_modified (line 67)[TimeHdr DriftELHdr DriftXELHdr DriftLOSHdr] = textread('fid', '%s %f %f %f');fid also returns -1, which indicates it wasn't opened.
Best Answer