Octave: 如何使用返回多个值的COM接口函数?

huangapple go评论58阅读模式
英文:

Octave : How to use a function of a COM interface that returns multiple values?

问题

在Matlab中,你可以使用返回多个值的ActiveX对象。

这是一个示例代码:

pkg load windows
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open('E:\Temp\del\a.xlsx');
worksheet = workbook.Worksheets.Item(1);
range = worksheet.UsedRange;
[numRows, numColumns] = size(range.Value);
workbook.Close(false);
excel.Quit();

这个代码在Octave中也可以工作。

但是,在Octave中使用的接口看起来像这样:

MyComObject.BeatArray(out EventTimes, BeatTypes, TemplateNumbers: OleVariant);

每个返回的参数都是一个双精度数组。你可以在Matlab中使用以下方式:

[a, b, c] = foo.BeatArray

但这在Octave中不起作用。
有办法在Octave中使用这个函数吗?

谢谢!

英文:

In Matlab you can use AxtiveX-objects that return multiple values.

Here's an example code:

pkg load windows
excel = actxserver('Excel.Application');
workbook = excel.Workbooks.Open('E:\Temp\del\a.xlsx');
worksheet = workbook.Worksheets.Item(1);
range = worksheet.UsedRange;
[numRows, numColumns] = size(range.Value);
workbook.Close(false);
excel.Quit();

This also works in Octave.

BUT: The interface I use looks like this:

MyComObject.BeatArray(out EventTimes, BeatTypes, TemplateNumbers: OleVariant);

and each returned parameter is a double-array. It can be used in Matlab using

[a,b,c] = foo.BeatArray

That does not work in Octave.
Is there a way to use that function in Octave?

Thanks!

答案1

得分: 1

  1. "COM"接口可通过windows包获得。

  2. 是的。只要您的函数返回多个输出,那么在Octave中捕获多个输出的方式与Matlab类似。请注意(与Matlab一样),一个由多个元素组成的单个输出不等同于多个输出。

英文:

Your question is actually 2 separate things.

  1. The "COM" interface is available via the windows package.

  2. Yes. As long as your function returns multiple outputs, then capturing multiple outputs works the same way in octave. Note that (like matlab), a single output consisting of multiple elements is not the same thing as multiple outputs.

huangapple
  • 本文由 发表于 2023年3月31日 18:16:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/75897368.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定