首先编写截图子函数并命名为 jietu_mdl。
function jietu_mdl(bpath) if nargin < 1 files=dir('*.mdl'); else [pathstr,name] = fileparts(bpath); if exist(bpath,'dir') name = [name '\*']; end ext = '.mdl'; files=dir(fullfile(pathstr,[name ext])); end if ~isempty(files) whandle = actxserver('word.application'); whandle.Visible = 1; Add(whandle.Documents); sel=whandle.Selection; set(sel.ParagraphFormat,'Alignment','wdAlignParagraphLeft'); set(sel.PageSetup,'LeftMargin',28.35,'RightMargin',28.35,'BottomMargin',28.35*1.43); for index=1:size(files,1) title=files(index).name; eval(title(1:end-4)); print('-dmeta',['-s', title(1:end-4)]); bdclose; close('all'); TypeText(sel,title); set(sel.ParagraphFormat,'KeepWithNext',-1) TypeParagraph(sel); Paste(sel); set(sel.ParagraphFormat,'KeepWithNext',0) TypeParagraph(sel); end release(whandle); end return
然后在 MATLAB 主界面运行调用截图函数 jietu_mdl('shiyan') 可得图。
如果觉得我的回答对您有用,请随意打赏。你的支持将鼓励我继续创作!