From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW MathScript RT Module

cancel
Showing results for 
Search instead for 
Did you mean: 

mathscript included structure

I had the following code:-
********************************************************************************************************8
 
function InitConnection(com, baud)
     %
     % Initialize the data pipe to the "Accelerometer Data Acquisition" device,
     % and send the initialization command to the device.
     %
     global data_pipe;    % Object used to connect to the "Accelerometer Data Acquisition" device
    
     % Initialize serial connection
     data_pipe = serial(com);
     % Configure COM port for serial communication
     data_pipeReadAsyncMode = 'continuous'; 
     data_pipe.BaudRate = baud;               % Set baudrate to the value specified in "baud"
     data_pipe.DataBits = 8;                  % 8-bit mode
     data_pipe.Parity = 'none';               % No parity
     data_pipe.StopBits = 1;                  % One stop bit
    
     fopen(data_pipe);                        % Open serial connection
 
******************************************************************************************************
when i compile, i get the following error:-
compiled.line 12:16: unexpected char: '.'
 
Seem like the structure is not supported by labview?Can anyone help me?
0 Kudos
Message 1 of 9
(8,934 Views)
Hello,

You are correct:  LabVIEW MathScript does not currently support the structure data type.  LabVIEW MathScript also does not currently have support for serial communication commands.  What commands would you find most useful?  We are aware of both issues and are considering adding support for them in a future release of LabVIEW.

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 2 of 9
(8,927 Views)

Hello,

Does Mathscript support the use of a cluster directly as an input or output to a Mathscript node? As i remember in Matlab syntax a cell would act similarly to a cluster... 

Thanks 

0 Kudos
Message 3 of 9
(8,273 Views)
Hello,

Unfortunately, cell arrays are also currently unsupported.  The MathScript node does not accept cluster inputs since neither the structure or cell array is currently supported within MathScript. A slight workaround is to use a separate variable for each element of a cell array or structure (e.g. instead of data_pipe.Parity use data_pipe_Parity).

Grant M.
Staff Software Engineer | LabVIEW Math & Signal Processing | National Instruments
0 Kudos
Message 4 of 9
(8,259 Views)

Since this is a currently a showstopper for us -  when will MathScript support structures? 

 

BR

 

Markus 

0 Kudos
Message 5 of 9
(7,553 Views)
Hello Markus,

As shown on the MathScript RT Module roadmap at NI Week 2009, structure support is currently slated for the LabVIEW 2011 release.  However, depending on how heavily you use structures, you can work around this limitation by changing the dot to an underscore.  In the example above, data_pipe.StopBits becomes data_pipe_StopBits.  You now have additional variables to pass around, but it may allow you to use your code.

Grant M.
Staff Software Engineer | LabVIEW MathScript | National Instruments
0 Kudos
Message 6 of 9
(7,550 Views)

Thanks Grant,

 

your suggestion is okay for a few structure elements. 

 

Unfortunately we currently have MathLab code with a lot of (sub) structure members where you have e.g.

a global structure variable definition on toplevel and assignments of this variable inside functions.

 

e.g. for a global variable "C1":

 

 

for iM = [C1.MsId.SelectIntraCell C1.MsId.SelectInterferer]

C1.MS{iM}.DATA.RNTI = PRS_RRHTest.RNTI;

C1.MS{iM}.DATA.ResourceBlock.StartingPRB = PRS_RRHTest.StartingPRB;

C1.MS{iM}.DATA.Channel.TFRC_idx = PRS_RRHTest.TFRC_idx;

C1.MS{iM}.DATA.Pilot.n_DMRS_2 = PRS_RRHTest.n_DMRS_2;

end

 

 

So support of structures and cell arrays inside MathSkript would be really great to replace (external) MathLab usage.

 

 

BR

 

Markus 

 

 

0 Kudos
Message 7 of 9
(7,547 Views)
Markus,

Indeed, structures and cell arrays certainly work together.  Cell arrays are an item we are investigating for the future, but we don't currently have any timeframe.  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.

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

Hello Grant,

 

since MatLab is the reference in this area of course it would be nice to have full support for all of its functionality.  

A free (open source, multi platform) alternative to MathLab could be "octave" (www.octave.org) where things like

structures and cell arrays are already implemented and which is already more compatible to MatLab than MathScript.

 

So to prevent a complete reinvention  (of the wheel) it would be nice to have a comfortable interface to tools like

octave. And one the other hand - this should be easier to implement and even faster. 

 

BR

 

Markus 

Message Edited by mul2636 on 12-08-2009 06:10 AM
Message Edited by mul2636 on 12-08-2009 06:11 AM
0 Kudos
Message 9 of 9
(7,497 Views)