Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

亲能请教个问题吗? #3

Open
COBY-CN opened this issue Nov 20, 2019 · 0 comments
Open

亲能请教个问题吗? #3

COBY-CN opened this issue Nov 20, 2019 · 0 comments

Comments

@COBY-CN
Copy link

COBY-CN commented Nov 20, 2019

我用您写的模板想使用子函数调用的方式使用,不知道为什么用不起,能指点一下吗?主要您写的这个版本我自己觉得比较看得懂,比较清晰。

在word里面写入文字,操作在一个.m文件中可正常执行

import mlreportgen.dom.*;
d=Document('demo2','docx');
open(d);

%% 标题
%-----------------------------------------------------------------------------------------
p=Heading(1,'Matlab 自动化报告模板');% 一级标题
p.Style={Color('red'),HAlign('center')};
%-----------------------------------------------------------------------------------------
append(d,p);

close(d);
rptview(d.OutputPath);

但是如果把上面标题部分内容放到子函数testtest里面就无法实现,如下面的写法

=================================================

import mlreportgen.dom.*;
d=Document('demo2','docx');
open(d);

% 调用函数
p = testtest(d);

append(d,p);

close(d);
rptview(d.OutputPath);

function out = testtest(d)

p=Heading(1,'Matlab 自动化报告模板');% 一级标题
p.Style={Color('red'),HAlign('center')};

out = p;

请问一下我怎么才能在子函数里面实现呢,因为如果我想大量的写入文件,想通过调用子函数的方式来实现。不知道是否有空指点一下,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant