How to use "saveas" without pressing "ok"?

1 次查看(过去 30 天)
I am trying to automate a Matlab script through Task Scheduler. The script works fine, but when I use the saveas function, a window still pops up asking if the filename to save it as is okay or if it should be cancel. I want it to save without this window popping up. Here is my script...
function concatFileName=myKWconcat(FileName,PathName)
PathName='T:\10 - VEHICLE TESTING RESULTS\2011 KENWORTH ISX15\10 - CANAPE FILES\1306\MAT_raw\'; FileName = mydatesearch(PathName);
S = struct('t',[]); for i=1:length(FileName) B = load([PathName char(FileName(i))]); l = length(B.t);
var_names = union(fieldnames(S),fieldnames(B));
var_new = var_names(~ismember(var_names,fieldnames(S)));
for j=1:length(var_new)
S.(var_new{j}) = zeros(length(S.t),1);
end
for j=1:length(var_names)
if isfield(B,var_names(j)) & length(B.(var_names{j}))==l
S.(var_names{j}) = [S.(var_names{j}); B.(var_names{j})];
else
S.(var_names{j}) = [S.(var_names{j}); zeros(l,1)];
end
end
disp(['File(' num2str(i) '/' num2str(length(FileName)) ') Done: ' char(FileName(i))]);
end
Base = strtok(FileName{1}, '_'); concatFileName = inputdlg('File Name:','Save As...',1,{[Base '_SPLBRENT3_concat.mat']}); saveas([PathName char(concatFileName)],'-struct','S','*');
clear B Base S i j l var_names var_new load([PathName char(concatFileName)]); clear concatFileName PathName

采纳的回答

Iain
Iain 2013-6-19
Your problem is:
concatFileName = inputdlg('File Name:','Save As...',1,{[Base '_SPLBRENT3_concat.mat']});
You should do "something" to make this line not apply, either by using an appropriate if statement, or by commenting it out. - But you'll still need to get a filename from somewhere.
  1 个评论
Lianna Johnson
Lianna Johnson 2013-6-19
Thank you very much! I actually didn't write that script so I didn't even know what that line was for. Thanks!!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by