How to call Matlab script from Labview using the Labview "Call Matlab Function" function

mycirclescript.m contains the following:
"r = 3
A = pi * r^2"
Labview program is simply the following:
"Open Matlab Session" with path to Release Name ("R2019b") in string constant.
followed by the "Call Matlab Session" function with .m file path selected with a control.
followed by the "Close Matlab Session"
All three functions have "Session Out" connected to "Session In" and "Error Out" connected to "Error In", with an indicator for Error Out
on the Close Matlab Session function.
This is the simplest possible script and I don't see Matlab open and the only thing returned
is the following error below"
Source: E:\LABVIEW\PROGRAMS\mycirclescript.m
Function Name: mycirclescript
MATLAB call returned the following error: Output argument "n" (and maybe others) not assigned during call to "niifm.RunFunction>getOutputArgumentsCount".

5 Comments

To address this issue, it seems that there might be a discrepancy between the variables used in your MATLAB script and how they are handled within the LabVIEW program. Specifically, it could be related to how the output variables are defined or assigned in your MATLAB script and how they are expected to be received in the LabVIEW program. To resolve this error, you may need to check the following: 1. Ensure that all output variables (such as "A" for area calculation) in your MATLAB script are properly defined and assigned values before the script terminates. 2. Verify that the output arguments in your MATLAB script match the expected input parameters in your LabVIEW program. 3. Double-check the data types of the variables being passed between MATLAB and LabVIEW to ensure compatibility. 4. Consider using error handling mechanisms within your LabVIEW program to better capture and handle any potential issues that may arise during the MATLAB script execution. By addressing these points and ensuring consistency between your MATLAB script and LabVIEW program regarding variable definitions, assignments, and data types, you should be able to troubleshoot and resolve the error you are encountering.
So you can't tell me if the block diagram I described in detail is the correct Labview syntax ?
and I have no idea how to do #2 & #3. The 'output variables' is just the area. The matlab script is text.
Do you see anything wrong with it ? (or with the Labview diagram I described ?) I have no idea how
the Labview Call Matlab Session function works or how it handles datatypes.
You know as much about it now as I do (probably more).
The Matlab Call function has one input arg (Input type) and one output(Return value) but the icon
does not allow me to create a constant for the input or an indicator for the output.
(not exactly since my script only has one input and one output)

Sign in to comment.

Answers (0)

Tags

Asked:

on 21 Jun 2024

Commented:

on 21 Jun 2024

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!