MATLAB: Strange error using readtable

cellcell arraysdebug4mefprintfMATLABreadtabletable2array

Greetings,
Having trouble with readtable with text files. The text files in question have a combination of text and number, thus the reason for using readtable. The script runs through the first two text files with no issues then crashes on the first line of the next text file.
while row <= height(workfile) %Height command identifies the number of rows in the table to stop the loop.
t=workfile(row, col); % t is a temp variable to store the date before processed by datenum
t=table2array(t); % convert to an array
t=datenum(t); % process to a datenum value
col=3; % set column to 3 to pull precip data
% now pull the precip data
p=workfile(row, col);
p=table2array(p);
Vdata=[t, p]; %temp variable to allow easier use of the fid process
fid=fopen (verfile , 'a');
fprintf(fid, '%6.0f, %7.4f \n ' , Vdata);
fclose(fid);
The datenum line executes fine but it appears the issue comes up with the fprintf command as I get this error
Error using fprintf
Function is not defined for 'cell' inputs.
Error in sitedata (line 95)
fprintf(fid, '%6.0f, %7.4f \n ' , Vdata);
LIke I said, this was not an issue with the previous text files that were sucessfully run before so I am stumped. Below is a sample of the text files in question:
10/31/2018 0 0
11/1/2018 0 0
11/2/2018 0 0
11/3/2018 0 0
11/4/2018 T 0.0001
11/5/2018 0 0
11/6/2018 0 0
11/7/2018 0 0
11/8/2018 T 0.0001
11/9/2018 0.19 0.19
11/10/2018 0 0
This is what the file before the one the crashed look like (top of the file).
Here is the one the script crashed on (same area of the file):
10/31/2018 0 0
11/1/2018 0.1 0.1
11/2/2018 0.45 0.45
11/3/2018 0 0
11/4/2018 0.5 0.5
11/5/2018 0.14 0.14
11/6/2018 0.11 0.11
11/7/2018 0 0
11/8/2018 0 0
11/9/2018 0.12 0.12
11/10/2018 0 0
Other than the data, they don't look any different. Any ideas??

Best Answer

I've downloaded brtyrpre.txt from your comments and copy&pasted brtyr_error_pre.txt from your question ("Here is the one the script crashed"). Next I run the script of your comment. brtyr_error_pre.txt was processed without problems and the script throw an the error for the first row of brtyrpre.txt.
>> Untitled
Processing file: brtyr_error_pre.txt
Processing file: brtyrpre.txt
Error using fprintf
Function is not defined for 'cell' inputs.
Error in Untitled (line 34)
fprintf( fid, '%6.0f, %7.4f \n ' , Vdata );
K>>
The the text of the error differs somewhat, but the message is the same. I run R2018b.
The reason for the error is that in one of the files there are letters among the numerical data (as Walter assumed). With letters among the numerical data the entire column is imported as character, without letters it's imported as double. When "extracting" a character column from a table you get a cell array, which causes the error.
"The script runs through the first two text files with no issues then crashes on the first line of the next text file." Run one file at a time to become 101% sure which file causes the error.
K>> workfile(1:3,:)
ans =
3×3 table
Var1 Var2 Var3
__________ ____ ____
10/31/2018 0 0
11/01/2018 0.1 0.1
11/02/2018 0.45 0.45
K>> workfile(1:3,:)
ans =
3×3 table
Var1 Var2 Var3
__________ ______ ______
10/31/2018 '0' '0'
11/01/2018 '0.1' '0.1'
11/02/2018 '0.45' '0.45'
And see