MATLAB: Help with sprintf, disp, load, strcat

concatfilefilenamesprintfstrcat

I have this script that plots a bunch of data and sends it to excel. I'm trying to automate the script so that it gets the day's file daily and plots and saves the data. Here is the beginning of the script…
function my_Dayplot_Emissions_KW_2011_v5(FileName,PathName,flag_plots,flag_writetoexcel)
PathName =('T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1306\MAT_raw\');
FileName = concatdatesearch(PathName);
flag_plots = 1;
flag_writetoexcel = 1;
%****
%Nomenclature
disp(sprintf('Running Dayplot Emissions.. %s',FileName));
S=load(strcat(PathName,FileName));
S.FileName=FileName;
S.PathName=PathName;
S.t=1:length(S.CAN1_EEC1_EngSpeed); %seconds
S.mat_time=S.XCP_MatlabTime_time;
S.code_ver=4;
The concatdatesearch function is needed to get the right concat file. The function works fine. However, the script does not work when I try to set FileName equal to that function. It only works when FileName = '20130622_SPLBRENT3_concat.mat'.
The error it shows is
Error using sprintf
Function is not defined for 'cell' inputs.
Error in my_Dayplot_Emissions_KW_2011_v5 (line 95)
disp(sprintf('Running Dayplot Emissions.. %s',FileName));
However this error does not show when I run the script when FileName = '20130622_SPLBRENT3_concat.mat'. And concatdatesearch(PathName) is equal to '20130622_SPLBRENT3_concat.mat'. What am I doing wrong?

Best Answer

Looks like concatdatesearch returns a cell array, not a character array. Try adding the line
FileName = FileName{1};
after your call to concatdatesearch.