MATLAB ActiveX 可选参数

发布于 2024-12-26 13:41:58 字数 1005 浏览 2 评论 0原文

有一个 ActiveX 函数,我想从 MATLAB 调用它,例如

PrintOut([Background], [Append], [Range], [OutputFileName], [From], [To], [Item], [Copies],
 [Pages], [PageType], [PrintToFile], [Collate], [FileName], [ActivePrinterMacGX],
 [ManualDuplexPrint], [PrintZoomColumn], [PrintZoomRow], [PrintZoomPaperWidth],
 [PrintZoomPaperHeight])

并按如下方式使用它:

hdlActiveX = actxserver('Word.Application');
hdlActiveX.PrintOut(opt args, needed args, opt opts, needed args);

PrintOut 函数调用中的所有参数都是可选参数。但是,对于特定情况,我需要指定参数 #3、#9、#10 并将所有其他参数保留为默认值。是否可以在通过 MATLAB 调用的 ActiveX 函数调用中指定缺失值或默认值?!?

在 C# 中可以这样完成,但在 Matlab ActiveX 中......?!?

this.PrintOut(ref Background, ref missing, ref Range, ref missing,
    ref missing, ref missing, ref missing, ref Copies,
    ref missing, ref PageType, ref PrintToFile, ref Collate,
    ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
    ref PrintZoomRow, ref missing, ref missing);

问候,

there is an ActiveX function, which I want to call from MATLAB, e.g.

PrintOut([Background], [Append], [Range], [OutputFileName], [From], [To], [Item], [Copies],
 [Pages], [PageType], [PrintToFile], [Collate], [FileName], [ActivePrinterMacGX],
 [ManualDuplexPrint], [PrintZoomColumn], [PrintZoomRow], [PrintZoomPaperWidth],
 [PrintZoomPaperHeight])

and use it like follows :

hdlActiveX = actxserver('Word.Application');
hdlActiveX.PrintOut(opt args, needed args, opt opts, needed args);

All arguments in the PrintOut function call are optional arguments. However, for a particular case, I need to specify argument #3,#9,#10 and to leave all other to default. Is there a possibility to specify missing or default values in an ActiveX function call invoked via MATLAB ?!?

In C# this could be done like this, but in Matlab ActiveX ... ?!?

this.PrintOut(ref Background, ref missing, ref Range, ref missing,
    ref missing, ref missing, ref missing, ref Copies,
    ref missing, ref PageType, ref PrintToFile, ref Collate,
    ref missing, ref ManualDuplexPrint, ref PrintZoomColumn,
    ref PrintZoomRow, ref missing, ref missing);

Regards,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故人如初 2025-01-02 13:41:58

根据Matlab文档,您可以跳过可选输入参数使用空数组代替(即[])。

所以这看起来像:

hdlActiveX.PrintOut([],needed args,[],needed args);

According to the Matlab documentation, you can skip optional input arguments by using an empty array instead (i.e. []).

So this would looks like:

hdlActiveX.PrintOut([],needed args,[],needed args);
白首有我共你 2025-01-02 13:41:58

我使用 NaN 作为默认/可选参数,它对我有用。所以我的版本是:

hdlActiveX.PrintOut(NaN, needed args, NaN, needed args);

老实说,我认为两者都可以正常工作。希望这有帮助!

I use NaN for default/optional parameters and it works for me. So my version would be:

hdlActiveX.PrintOut(NaN, needed args, NaN, needed args);

Honestly, I think both would work fine. Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文