LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

[Matlab Node Script] It runs but: outputs of Matlab function are not the proper

Hi.

I'm using Labview 8.6 combined with Matlab between Matlab Script Node and I have some problems. Im using Matlab R2008a. In Matlab i’m using the ident toolbox to identify some processes given a data text archive.

 

I have a function that depends on another functions that doesn't works fine when it’s called from Matlab Script Node.

 

I have test the function on Matlab and it shows me the proper results. But when I put it on Labview with Matlab script Node (I’ve also probed to put it on Mathscript node and it doesn’t work either) doesn’t give me the correct values (the same values that I have obtained when I’ve call the function from Matlab).

 

I think that the problem is in my code, so that I will give you all the functions I’ve used for accomplish my purposes and the used VI.

(I’ve only revised* the functions made by me, and not the rest of them, I suppose that they don’t have characteristics that Matlab don’t give support to )

*that there aren’t any characteristics of Matlab language that Matlab Script Node don’t support. (I read on NI forums that Labview (actually Matlab Script Node) doesn’t use Matlab structures correctly when you put them in the form “variable.field” (using the “.” Operator) and because of this fact, i have modified the syntaxis of all the structures that i put before; moreover: i’ve read that it also doesn’t works fine with arrays of 3D or more ).

 

To resume, I will be so happy if anybody wants to read my code for searching any incompatibility between certain expressions and Matlab Script Node.

 

In order to do the work easier, I copy the list of variables returned and arguments that are necessary to send to the main function “AsignacionPolosssVER2”. Moreover, I put it, certain values for the inputs and the CORRECT values of outputs of the function for these certain values, in order to set a reference to distinguish if the VI runs fine or not.

 

 

Archives made by me:

-scriptaparte.vi

-saturacion.m

- cal_procesodiscreto.m

- cal_procesocontinuo2VER2.m

- cal_procesocontinuo2VER2.m

 

NOTE: change the path given to the variables “pa” and “ruta_ar” (in “scriptaparte.vi”) “D:\Documents and Settings\Administrador\Escritorio\scriptnode2\datos7p75.txt” (path + name of data archive) and “D:\Documents and Settings\Administrador\Escritorio\scriptnode2” (path) from the correct ones in your case.

 

Main function prototype:

function [numreg,denreg,Tmuestreo,status,num_gs,den_gs,delay,numd,dend,bestPer,bestMod,FITf,Modelable,sat]=AsignacionPolossVER2(metodo,espd,ptodis,espe,CancelacionCeros,ruta,FITumbral,n)

 

Charging certain values:

 

[numreg,denreg,Tmuestreo,status,num_gs,den_gs,delay,numd,dend,bestPer,bestMod,FITf,Modelable,sat]=AsignacionPolossVER2(0,[0 3 3],[-3 5],1,'s','I:\LabVIEW 8.6\examples\scriptnode2\datos7p75.txt',3,0)

 

 You only have to copy this on Matlab to view the results. However i put it the correct values of outputs for this inputs:

 

numreg =[309.4818 -305.4845]

denreg =[1.0000    1.5445]        Tmuestreo=0.015       status=1

num_gs = 0   -0.3310    0.7064

den_gs =    1.0000    0.2858         0         delay=0.45

numd=-0.0049    0.0050

dend=    1.0000   -1.9957    0.9957

bestPer =  91.2001

bestMod ={'P1IZD';}

FITf =91.2001

Modelable =1

sat =

 

     1   526

     0     0

     0     0

     0     0

     0     0

     0     0

     0     0

     0     0

     0     0

 

    My opinion: I think that the the program is not well interpreted by Matlab Script Node because when the VI prints all the outputs for all the models (output to the instruction compare(model1,...modeln), the correct (the model which has the best fit -percentage-) model has a different percentage of similarity to the data (in both cases i’m using the same .txt to load the data). Some output variables are right (ie. Tmuestreo).

I give you the folder where i’m working.

 

Sorry, but my english is not so good.

 

(If anybody speaks Spanish well, i accept to be replied on this language)

 

 

Thanks.

 

Oscar.

0 Kudos
Message 1 of 4
(7,025 Views)
Sorry, i've forgotten to give you a link to my archives: http://www.megaupload.com/?d=K9G6NXZ8
0 Kudos
Message 2 of 4
(7,024 Views)
Hello,

It sounds like there might be some confusion between the MATLAB script node and the MathScript node.  In LabVIEW MathScript, you generally can execute scripts written in the MATLAB® language syntax.  However, the MathScript engine executes the scripts, and the MathScript engine does not support some functions that the MATLAB software supports.  In order to use the MATLAB script node, you need to have The MathWorks, Inc. MATLAB software installed.

Currently, structures and cell arrays are not supported by the MathScript node.  I tried your code in the MathScript node, and it uses a lot of cell arrays.  However, if you use the MATLAB script node, the MATLAB software executes your scripts.  It shouldn't have a problem with cell arrays or structures.  You mention the inability to use 3D arrays.  This is only a limitation in providing inputs or retrieving outputs from the MATLAB script node.  Within your script, you should be able to use 3D arrays.  I have alerted my colleagues to this post as they will have more information about the MATLAB script node support.

MATLAB® is a registered trademark of The MathWorks, Inc.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 3 of 4
(6,986 Views)

Hi Oscar,

 

I was not able to execute your m files. It appears that I'm missing the file containing iddata's functional definition. Please attach that file and I will see if I can execute your files.

 

Thanks, 

Sappster
0 Kudos
Message 4 of 4
(6,970 Views)