필터 지우기
필터 지우기

Help with sprintf, disp, load, strcat?

조회 수: 3 (최근 30일)
Lianna Johnson
Lianna Johnson 2013년 6월 24일
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?

채택된 답변

Kelly Kearney
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.
  댓글 수: 1
Lianna Johnson
Lianna Johnson 2013년 6월 24일
That fixed it! Thank you so much

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Text Data Preparation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by