Help with sprintf, disp, load, strcat?
3 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
采纳的回答
Kelly Kearney
2013-6-24
Looks like concatdatesearch returns a cell array, not a character array. Try adding the line
FileName = FileName{1};
after your call to concatdatesearch.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!