From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

How to return struct from a MathScript function?

Solved!
Go to solution

Could someone guide me how to return struct from MathScript node if I have something like this in it:

[stat.mymax, stat.mymin] = mymaxmin(1, 2)

The script looks like this:

function [mymax, mymin] = mymaxmin(a,b)
%max min
mymax = max(a,b);
mymin = min(a,b);
end

And the code:

 Node.png

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 1 of 3
(4,791 Views)

It seems that output will not be automatically assigned because mymaxmin function is included in run time with addpath function...

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 2 of 3
(4,772 Views)
Solution
Accepted by topic author bienieck

To close the subject:

To be able to automatically assign output structure in a custom function I needed to set MathSript Search Paths: Tools > Options >MathScript > Search Paths.

From my understanding, it will never work with addpath() and in such case, I need to manually assign output data types (and I believe struct will not be an option).

Case closed.

Michał Bieńkowski
CLA, CTA, CPI

  1. Did someone devote their time to help solve your problem? Appreciate it and give kudos.
  2. Problem solved? Accept as a solution so that others can find it faster in the future.
  3. Contribute to the development of TestStand by voting on the TestStand Idea Exchange.
0 Kudos
Message 3 of 3
(4,760 Views)