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

2 views (last 30 days)
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

Accepted Answer

Iain
Iain on 19 Jun 2013
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 Comment
Lianna Johnson
Lianna Johnson on 19 Jun 2013
Thank you very much! I actually didn't write that script so I didn't even know what that line was for. Thanks!!

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!