1 simulink 仿真图如何转化成图片格式

  • 3993
请先 登录 后评论

1 个回答

CSUA - 研究生
擅长:LS-DYNA

首先编写截图子函数并命名为 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') 可得图。

请先 登录 后评论