LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

Use of user defined function in mathscript containing structure

Solved!
Go to solution

Hi, I am an beginner user of LabView's MathScript Module,

I have the following problem when integrating my MATLAB code into LabView, for HMM:   In my program, I tried to call a user defined MATLAB function called 'mixgaussinit.m' It show this error ..

"

Error -90162 occurred at Line 36, Column 20: unexpected char: '.'
C:\HMMall\KPMstats\mixgauss_init.m

 

 

 

Possible reason(s):

LabVIEW:  A recognition error occurred while generating a stream of tokens.

"

the line 36 of the file is this "mu = reshape(mix.centres', [d M])"

mix.centers is a structure.. 

 How can this error be corrected?

 

0 Kudos
Message 1 of 6
(7,117 Views)

Hi interstellar,

 

Currently MathScript does not support the use of structures or cell arrays. One workaround would be to use a separate variable for each element of a cell array or structure (e.g. instead of mix.centres use mix_centres). Would it be possible for you to share more of your m code?  Any use of structures and cell arrays will greatly help us define and scope the important use cases to support in MathScript. 

 

Regards,

 

K Scott 

0 Kudos
Message 2 of 6
(7,112 Views)

Hi Scott.. Thank you for replying.. Actually the variable are passed from a different function in form of a structure.. So converting the variable for example to mix_centers would be difficult because there are too many variable... Isnt there any other way to do the same?

I'm attaching the m file(its in txt format because .m is not supported).. error in line 36 column 20..

Thank you

 

Regards

0 Kudos
Message 3 of 6
(7,102 Views)

Without knowing anymore about the gmm and gmminit functions defined in your script I am unable to recommend a solution. Based on what I can see, I recommend that you modify those functions to return the variables required in this script (e.g. mix.centres, mix.covars, etc...) Other than that I can only say that structures support is something we hope to offer in a future release of MathScript.

 

Regards,

 

K Scott

0 Kudos
Message 4 of 6
(7,081 Views)

Well, then if i mail you the above mentioned function will you be able to find any other solution?

thanks for your reply..

Regards.

0 Kudos
Message 5 of 6
(7,069 Views)
Solution
Accepted by topic author interstellar

I just noticed that these files appear to be under copyright. My first question is do you have the copyright permissions to post them in a public forum? If not then you may wish to delete them. That being said I have examined the code and it seems easy enough to work around your issues (provided you have the copyright permissions). The way to work around the issues is indeed to replace the struct fields with variables. This will of course require you to change a couple function definitions to input and output the neccesary variables which I believe was at most 5 variables. You will also need to redo the error checking code that uses a cell array. Altogether I estimate about 30 minutes of work. I would have given you the work around in these files had the files not been copyrighted. So, unfortunately, you will have to implement the work around yourself.

 

Good luck!

 

K Scott

0 Kudos
Message 6 of 6
(7,061 Views)