LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert Matlab code to labview without using Mathscript ?

I am working with LabVIEW 2023 and MATLAB 2023. I want to convert MATLAB code and its associated functions to LabVIEW without using MathScript. When I use MathScript, I obtain the results figures and windows as if I were using MATLAB. I desire to display and visualize the results using LabVIEW's graphical elements rather than MATLAB's.

How can I convert Matlab code with its related functions to Labview ?

 

Thanks 

Best Regards.

0 Kudos
Message 1 of 10
(1,050 Views)

Hi HUSAM,

 


@HUSAM2324 wrote:

How can I convert Matlab code with its related functions to Labview ?


By recreating the code in LabVIEW…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 10
(1,039 Views)

Thank you for replying @GerdW 

how can I do that ? May you give me the instructions ?

0 Kudos
Message 3 of 10
(1,019 Views)

Hi Husam,

 


@HUSAM2324 wrote:

how can I do that ? May you give me the instructions ?


Analyze the MATLAB code and recreate its functionalities using LabVIEW functions.

Which (other) kind of instruction do you need/expect?

 

Simple example:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 10
(1,016 Views)

Hi GerdW

From your explanation, I gather that I need to recreate the system coded in MATLAB within LabVIEW, the code is long and implementing it in LabVIEW will be a bit difficult. Is there any tool available to directly convert the code to the LabVIEW environment? If not, how can I display the results using LabVIEW's graphical elements when using MathScript?

0 Kudos
Message 5 of 10
(996 Views)

Hi Husam,

 


@HUSAM2324 wrote:

From your explanation, I gather that I need to recreate the system coded in MATLAB within LabVIEW, the code is long and implementing it in LabVIEW will be a bit difficult. Is there any tool available to directly convert the code to the LabVIEW environment?


AFAIK there is no tool to create LabVIEW code from a MATLAB source.

(You might create a DLL from your MATLAB code and call that DLL. I don't know if that will result in less work…)

 


@HUSAM2324 wrote:

If not, how can I display the results using LabVIEW's graphical elements when using MathScript?


Delete the plotting commands in MathScript and wire the data to LabVIEW indicators, like XYGraph or WaveformGraph…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(989 Views)

See Integrating Compiled MATLAB Functions with LabVIEW with a .NET Assembly Approach or Using DLLs Built with MATLAB Coder in LabVIEW

-------------------------------------------------------
Control Lead | Intelline Inc
Message 7 of 10
(918 Views)

@HUSAM2324 wrote:

Hi GerdW

From your explanation, I gather that I need to recreate the system coded in MATLAB within LabVIEW, the code is long and implementing it in LabVIEW will be a bit difficult. 


A number of the responses to your original question are seasoned LabVIEW Developers -- several are even LabVIEW Champions!  Why don't you post your Matlab code (you can just attach the .m file, assuming it involved with a GUI, but is straight Matlab code) and let us get a better idea of what might (or might not) be practical?

 

Bob Schor

0 Kudos
Message 8 of 10
(882 Views)

Thank you  GerdW 

                   ZYOng

            and Bob_Schor for your assistance.

My objective is to execute this MATLAB code along with its functions on a USRP 2943R device, utilizing LabVIEW in the process. Initially, I assumed that converting the MATLAB code to LabVIEW would be necessary, followed by adjustments for compatibility with the USRP device. However, I'm unsure if this approach is accurate. Please provide any suggestions or guidance.

 

The MATLAB code I wanted to convert to LabVIEW is attached below.

0 Kudos
Message 9 of 10
(854 Views)

Hi Husam,

 


@HUSAM2324 wrote:

My objective is to execute this MATLAB code along with its functions on a USRP 2943R device, utilizing LabVIEW in the process. Initially, I assumed that converting the MATLAB code to LabVIEW would be necessary, followed by adjustments for compatibility with the USRP device. However, I'm unsure if this approach is accurate.


You can use MathScript to execute your MATLAB code. Or you can translate all that code into LabVIEW VIs. (And some other options were mentioned too.)

 

So which way do you want to take?

 

Edit: I started a simpler m-file:

(I'm not a MATLAB expert, so please cross-check my approach.)

 


@HUSAM2324 wrote:

The MATLAB code I wanted to convert to LabVIEW is attached below.


Generic advice: please don't use proprietary software to create archives.

Any computer can handle ZIP nowadays, for RAR you need some special software!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 10
(819 Views)