LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Matlab function refuses to run in the mathscript

Hi,

I tried to run a function.m (call_osc) that calls another function.m (osc).

It is working and plotting perfectly in matlab but when I I include them in mathscrip window after adding the 2 functions in the appropriate folder I get an error saying that y in unknown.

I tried also to add both functions in the mathscrip structure. But no success.

Could someone help me to solve this problem, please?

It will be great if I have all the code together in one windows instead of calling different functions.

Thanks

0 Kudos
Message 1 of 3
(3,015 Views)

Zied,

 

     It can be challenging enough to program in one language (LabVIEW) without having to worry about putting some of the code in another language (Matlab).  Take a look at what you are asking the Matlab code to do.  Your function "Call_osc" calls an ODE solver that requires a reference to the function you wish to solve, namely the parameter "@osc".  For this reason, Matlab requires two functions (or a lot of obscure Matlab code).

 

     Have you considered simply doing away with the MathScript node and "letting LabVIEW Use LabVIEW", i.e. use LabVIEW functions instead?  [I'll confess I haven't looked to see if LabVIEW has the appropriate solver ...].

 

Bob Schor

0 Kudos
Message 2 of 3
(2,969 Views)

Bob,

 

It might be easier to utilize an ODE solver VI to perform the necessary calculations. Here is a link to the documentation on the ODE solver VIs available in LabVIEW: https://zone.ni.com/reference/en-XX/help/371894G-01/lvsimconcepts/sim_c_ode/. Examples utilizing ODE solvers can be found inside of LabVIEW >> Help >> Find Examples >> Analysis, Signal Processing and Mathematics >>Differential Equations - ODE.

 

Josh

0 Kudos
Message 3 of 3
(2,937 Views)