Effacer les filtres
Effacer les filtres

Help with sprintf, disp, load, strcat?

3 vues (au cours des 30 derniers jours)
Lianna Johnson
Lianna Johnson le 24 Juin 2013
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?

Réponse acceptée

Kelly Kearney
Kelly Kearney le 24 Juin 2013
Looks like concatdatesearch returns a cell array, not a character array. Try adding the line
FileName = FileName{1};
after your call to concatdatesearch.
  1 commentaire
Lianna Johnson
Lianna Johnson le 24 Juin 2013
That fixed it! Thank you so much

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Text Data Preparation dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by