0

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!

ralfiii
  • 584
  • 4
  • 13

1 Answers1

0

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.

Tasos Papastylianou
  • 21,371
  • 2
  • 28
  • 57
  • Thanks Tasos. I tried and it really works, it the interface only returns eg integers, but it fails with arrays. I updated the question... – ralfiii Apr 12 '23 at 12:50
  • What does "does not work" mean exactly. Does it give an error that might help decipher the problem? Also, does it change anything if you call it as a function with empty brackets? Are you sure the `foo` object has a `BeatArray` field? Does anything happen if you call it with only a single output argument? Are you definitely working on windows? – Tasos Papastylianou Apr 12 '23 at 21:12
  • Octave responds with "error: com_get: property/method invocation on the COM object failed with error `0x8002000e' - Unzulässige Parameteranzahl." (that's "invalid number of parameters"). I get the same error, if I write "a = beatchan.BeatArray". I can use "x=1;y=1;z=1;a=beatchan.BeatArray(x,y,z);" That returns "a = [](0x0)" but x,y and z remain unchanged. – ralfiii Apr 14 '23 at 08:29
  • Right. I don't have your data to test on my machine (and even if I did I'm not on windows), but that error message suggests to me that you're calling this with either the wrong number of expected input arguments, or the wrong number of expected output arguments. Or both. What does the documentation of "BeatArray" say? Also, are you sure you're passing the right type of argument? (I don't know much VBA, but the names imply arrays rather than single values). I don't know why you'd expect x,y,z to change after the call; they shouldn't. Perhaps the last form is correct, and the output is really [] – Tasos Papastylianou Apr 14 '23 at 10:36
  • Oh. Found the problem which was preventing writing the data to the range. The array formatting is also sent to Excel as a 2D table. But it should be transposed! If not, the first row is just repeated to the end of the array. Don't know why does it repeat and not leave the remaining cells void. – Asdf Aug 28 '23 at 03:23