LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

different result matscript and matlab

hi everyone. I use mathscript run pass fmincon in LV,but the different result from matlab.Despite the same code.Anyone help me.As soon as possible!!
0 Kudos
Message 1 of 7
(8,822 Views)

Can you please be a little more specific about what you are doing and what behavior you are seeing?  I opened the zip file and looked at the m file and VI, but the controls and indicators are very expressive.  Also, is the attached m file your comparison file or is there another file to which you are comparing your Mathscript VI?  What is the difference in the output? 

 

 

Nick Keel 

Applications Engineering 

National Instruments

Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments
0 Kudos
Message 2 of 7
(8,805 Views)

I got some difference beetween labview (v. 8.2) MathScript Node and Matlab (v.7.1.0.246 (R14) Service Pack 3) too. Im using the filtfilt function and get edge effects in LabView and not Matlab. You can see this problem in my screenshot below. Nothing fancy but how does LabView run the matlab code? Isnt using Matlab at all? I also post a plot with the filtered signal (y) from filtfilt in Matlab (red) vs and MatchScript Node (blue) and they are a bit diffrent in the noisy part.

 

Download All
0 Kudos
Message 3 of 7
(8,675 Views)

Hi Tudor,

 

That looks like it may be an issue with the way the waveform graph indicators display values.  If you look at the array data numerics, are there different values at the edges?  I think the values may be the same, but the waveform graph may just connect to zero at the edges.  One other problem may come from indexing, and the fact that Matlab indexes at one while LabVIEW indexes at 0.  Does the data come with any inherent indexing information?  

 

 

Nick Keel 

Applications Engineering 

National Instruments

Nick Keel
Product Manager - NI VeriStand and Model Interface Toolkit
National Instruments
0 Kudos
Message 4 of 7
(8,651 Views)
Hello Tudor,

We are looking into what might cause such edge effects.  Would it be possible to attach some sample data that also exhibit the problem?  This will help us debug the issue.

As far as LabVIEW running your m-file code, this is done in MathScript.  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.

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

Grant M.
Senior Software Engineer | LabVIEW MathScript | National Instruments
0 Kudos
Message 5 of 7
(8,584 Views)

Hi all,

 

I have noticed these edge effect before in MatLab Vs LabVIEW.  Going back a few years mind.  I think there were a couple of issues.  One being that i think NaN was handled differently in my use case and also the type of zero order hold vs First order hold that matlab and LV do is different  I believe i got around my problem by using a first order hold on my data set before passing it to the filter functions within LV.

 

Craig

LabVIEW 2012
0 Kudos
Message 6 of 7
(8,579 Views)
Hello Tudor,

We have investigated this issue some.  It seems that LabVIEW versions 8.6 and previous used zero padding in the implementation of the MathScript filtfilt function.  From your screenshot, it looks like you may be using LabVIEW 8.2.  The implementation was changed in 2009.  Can you try your VI again in LabVIEW 2009 with the MathScript RT Module?  If you still see the difference, can you post a VI with data that exhibits the problem?

Grant M.
Senior Software Engineer | LabVIEW MathScript | National Instruments
0 Kudos
Message 7 of 7
(8,529 Views)