Error using textscan, when trying to read in the first two columns of a text file
古いコメントを表示
I am trying to use the following code to read in a text file.
%Get events from text file
prompt_totalfiles = 'Enter number of files you want to input: '; %asks for number of files
total_files = input(prompt_totalfiles);
fileNames = cell(total_files,1);
for file = 1:total_files
[inputfile,path] = uigetfile('*.txt');
fileNames{file} = fopen(inputfile);
end
j = 1;
Baseline_adjustment = 0.1; %put in baseline photodetector value here (the readout with the led on but the patch cable in pitch black
dff1=[];dff2=[];dff3=[];dff4=[];dff5=[];dff6=[];dff7=[];dff8=[];dff9=[];dff10=[];dff11=[];
wholedff={dff1,dff2,dff3,dff4,dff5,dff6,dff7,dff8,dff9,dff10,dff11};
%Read formatted data from text file
for file = 1:total_files
b = textscan(fileNames{file},'%n %n', -1, 'delimiter', '/t');
This is the error I receive:
Error using textscan
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in StimulusTestNew (line 17)
b = textscan(fileNames{file},'%n %n', -1, 'delimiter', '/t');
The text file I wanna read in is this: I want to read in only the first two columns.

Can you please help me? Thanks!
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Data Import and Export についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!