Lanciare un file di Matlab da LabVIEW

Ciao a tutti,
il mio problema è semplice: mediante l'utilizzo di LabView vorrei lanciare un file (.m) di Matlab.
Voglio
premettere che conosco la funzione MATLAB Script, che mi permette di
inserire all'interno del riquadro il codice Matlab, ma in questo modo
non ho la possibilità di disporre nel workspace di Matlab delle
variabili di interesse.
Attualmente sto provando ad utilizzare
lo strumento virtuale System Exec.vi per abilitare, mediante
l'opportuno percorso, il file di Matlab. Sebbene in questo caso Matlab
si avvii correttamente, il file .m non viene lanciato.
Per vostra informazione dispongo della versione LabView 8.5 e della versione Matlab 7.3
In sostanza non so se sia possibile mandare in esecuzione un file di Matlab direttamente da LabView.
Avete avuto qualche esperienza a rigurado? E' possibile realizzare questa funzionalità?

Ciao Fabio,
rispondo ai tuoi quesiti:
nel "command line input" della funzione
"System Exec.vi" ho puntato direttamente al file .m
Ho dapprima verificato che i file .m fossero associati all'applicazione Matlab.
Ho provato poi, su tuo consiglio, ad eseguire la funzione "System Exec.vi" due volte, ovvero in serie, (una per aprire il Matlab ed una per caricare il file .m). Il risultato non cambia mi apre sempre Matlab ma per avviare il file somma.m devo digitare il nome del file dal Command Window di Matlab (a questo proposito ho allegato la figura). Il workspace di Matlab (parte sinistra della figura) rimane ovviamente vuoto.
Io vorrei invece lanciare il file somma.m direttamente da LabView, senza passare per il Command Window di Matlab. Non se tuttavia se questo sia fattibile.
Cordiali saluti,
Andrea
Attachments:
matlab_window.jpg ‏1540 KB

Similar Messages

  • Ejecutar m files de matlab desde labview

    Hola!
    Me gustaría saber cmo es posible ejecutar m-files de matlab desde Labview, es decir llamar desde Labview que se ejecute un m-file ya creado y poder recuperar la información resultante como puede ser un conjunto de matrices. No se si puede hacer directamente con el labview o hace falta alguna toolkit concreta.
    Muchas gracias

    Larson09
    Si tiene el paquete completo o profesional de Labview entonces tiene el script de Matlab ( lo puede encontrar en paleta de funciones>>Análisis>>Matemáticas>>Formula>>Script de Matlab.
    Para que le funcione este script debe tener instalado matlab, y dentro del script puede ejecutar directamente código de Matlab.
    Espero que esto le ayude
    Atentamente
    Belens

  • Creating .mat files with Matlab dataplugin in LabVIEW

    I am trying to create a .mat file in LabVIEW using the Matlab dataplugin. It appears to create a group called "Vector" without being told to, and it also concatenates group and channel names together. I have made an example to demonstrate this behaviour. I am trying to create a group called "Group" and inside it a channel called "Channel". What I get looks like a group called "Vector" and inside it a channel called "GroupChannel". What am I doing wrong?
    Best Regards,
    John Sackett
    Solved!
    Go to Solution.
    Attachments:
    write mat example.zip ‏54 KB

    Hello John
    Thank you for getting in touch regarding your issue. I am an applications engineer here at National Instruments, as I understand you are using the data plugin for Matlab within LabVIEW, but as shown with your code when you label the channel or group you get an outcome which you don't expect.
    I have opened and had a look at your code and can see where the issue is arising. The functions you are using are normally used with TDM files, .MAT files are compatible but there are a few differences between the file formats, which is why you are getting the outcome we have seen. A TDM file has headers named channelgroup and channel, but Matlab does not have the channelgroup header in the file type and therefore the functions in LabVIEW merge the 2 strings to the available header.
    I am not able to open your .MAT file so could you give me a brief description of what occurs inside Matlab?
    Have you looked into using the script node to allow for .MAT file types in LabVIEW? Here is the help file
    I have also found some resources which you may find useful.
    LabVIEW to MATLAB
    Convert file
    Open .MAT in LAbVIEW
    DataPlugin
    Let me know if you would like any further information
    Regards
    Stephanie L
    Applications Engineer
    National Instruments UK and Ireland

  • How to read labview binary files in Matlab

    I would like to read Labview binary files with Matlab. I read some articles of the subject and I am more interesting in know how labview store this data into file. What is the format use by Labview to store this data?
    Any help is appreciated,
    Hernando

    The term "binary file" means that the data on disk is a (pretty close) duplication of the binary format of the data in memory.  For example, a String will appear as an array of Bytes that, if looked at with a text editor, would be "human-readable".  
    An I32 or U32 integer would take 4 bytes, but the order (or "Endian setting") can be Big-Endian or Little -Endian (and I won't confuse both of us by trying to say which is which).  Thus the number "1" would appear as four byte of 0, 0, 0, 1 or 1, 0, 0, 0.  Floating point (Dbl) also has an "Endian" consideration, but the numbers are encoded as a mantissa and exponent, with sign appearing somewhere.  However, if you get the Endian and precision (Sgl, Dbl, etc.) right, both MatLab and LabVIEW should be able to read each other's data.
    Be careful with Booleans.  It wouldn't hurt to do an experiment and see how many bits/bytes are used for simple Boolean data.
    One other "gotcha" -- in LabVIEW, you can prepend Array and String writes with a U32 that is the length of the Array/String -- you obviously want to take this into account.
    Something that I've found helpful when dealing (in both Matlab and LabVIEW) with "unknown" binary data files is to use an old-fashioned "binary editor", something capable of displaying a file as Text and Bytes.  Strings "stand out", and if they seem to be preceded with 4 bytes that are mostly 0 with one Byte more-or-less the length of the String (sign that String Length was prepended).  If you see a lot of byte data that look like they could be 2 or 4 byte integers, they probably are.  If they are four bytes of numeric data that have few zero bytes (i.e. if most of the 32 bits seem to be used), they may well be floats.  Make a guess at the format and write a short routine to read according to your guess -- do you get meaningful data?  Go ahead, be a Scientist, not an Engineer -- study the data, form a hypothesis, then design and do an Experiment and see if you need to reject your hypothesis ...
    Bob (Neuroscientist) Schor

  • I would like to know how i can save an byte array to a mat file format (matlab file format '*.mat') within to use the matlab API

    So, I search the binary matlab file format('*.mat').

    Title:
    Moving Data Between MATLAB® and LabVIEW
    Problem: 
    How can I share data between LabVIEW and the MATLAB environment?
    Solution: 
    MATLAB users can move data between the
    MATLAB environment and LabVIEW, you have several options. Prior to
    LabVIEW 5.1, the only way to transfer data between these two
    environments was to use the Save and Load functions. Those are discussed herein.
    Beginning
    in LabVIEW 8.0, MathScipt was introduced. MathScript is an integrated
    part of LabVIEW that you can use to combine intuitive graphical
    dataflow programming with math-oriented textual programming. See the
    attached links below for more information on MathScript.
    Beginning
    in LabVIEW 5.1, the MATLAB script node was introduced into the LabVIEW
    programming environment. The MATLAB script node makes ActiveX calls to
    the MATLAB software from within LabVIEW. This requires that both MATLAB
    be installed on the same machine and that a valid license is obtained.
    More information on the MATLAB script node can be found in the attached
    KB's.
    For all versions of LabVIEW, this data transfer can be
    performed by saving the data in a file using the MATLAB software and
    reading it directly from LabVIEW, or vice versa. In the MATLAB
    environment, the command "save" allows you to save the data in
    binary format (*.mat) or ASCII format. You also have an option of
    saving it in ASCII format using a tab delimiter between data points and
    the command "load" allows you to read in the data.
    ASCII Format
    Complete the following steps to import or export data between LabVIEW and the MATLAB environment using an ASCII file format.
    From the MATLAB environment to LabVIEW
    To save a vector or a matrix X in tab-delimited ASCII format, enter the following in the command window or m-script file in the MATLAB environment:
    >>SAVE filename X -ascii -double -tabs
    This creates a file named filename containing data X in tab-delimited ASCII format.
    Import the file into LabVIEW using the Read From Spreadsheet File VI located on the Functions»File I/O palette.
    From LabVIEW to the MATLAB environment
    To export a matrix X from LabVIEW to the MATLAB environment, first save the data in ASCII format in LabVIEW using the Write To Spreadsheet File VI on the Functions » File I/O palette.
    Enter the following in the command window of the MATLAB environment, or in the m-script file:
    >> LOAD filename
    This reads the data into the MATLAB environment.
    Binary Format
    Complete the following steps to import or export data between LabVIEW and the MATLAB environment.
    From the MATLAB environment to LabVIEW
    As mentioned above, LabVIEW does not save multiple variables to one
    data with extra manipulation, and will not be discussed here.
    Therefore, the only way of sending the data from the MATLAB environment
    to LabVIEW without tampering with the MAT binary file structure is
    using the ASCII format. Also, please bear in mind that you need to have
    one file for one variable.
    From LabVIEW to the MATLAB environment
    Because
    the MATLAB software saves data in its own binary format, the "MAT"
    file, binary LabVIEW data must be converted to this format prior to
    transferring the data. The attached examples can be used to save
    LabVIEW data in the MATLAB software format. The convenience of the .MAT
    file format is that more than one variable can be saved in the same
    file. The example shows saving seven variables to .MAT format; the
    example can be modified for any number of variables.
    Once this data is saved from LabVIEW, it can be read into the MATLAB environment, using the following command:
    >>LOAD filename
    The Who
    command can then be used to display all the seven variable names, and
    you can display the content of them by entering the variable names at
    the command prompt as usual.
    MATLAB® is a
    registered trademark of The MathWorks, Inc. Other product and company
    names listed are trademarks and trade names of their respective
    companies.
    | Michael K | Project Manager | LabVIEW R&D | National Instruments |

  • How to read binary file in Matlab

    "Hello all!
    Labview 7.0 has an example "Cont Acq to File (binary).vi" log the PCI 6014 card and writes the data to a binary file. How can I read that
    file in Matlab(6.5.0... R13)? Does anyone have a solution for this?

    Hello,
    Basically you can do it by saving the data in a file in MATLAB and reading it directly from LabVIEW, or vice versa. In MATLAB , the command "save" allows you to save the data in binary format (*.mat) or ASCII format. You also have an option of saving it in ASCII format using a tab delimiter between data points.
    There is a knowledge base which talks in detail about how to share data in between labview and matlab Import data from labview to Matlab and vice versa.
    Hope this helps. If not, please feel free to ask more questions.
    Good luck and have a great day!
    Koninika
    National Instruments

  • How to write an .fds file using Matlab

    Hi there,
    Is there a way to use Matlab to create a ".fds" (Digital filter design file) so that it can be used in Labview. Alternatively, is there a way to create some arbitrary filter in labview to get this .fds file? More specifically, I am trying to implement some 11th order transfer function and using the "Create a Filter" VI in the labview examples to convert my code to Labview FPGA code. I am using the PXI-7833R (FPGA).
    Thanks for the help,
    Herrick

    Hello Herrick,
    I would recommend using the NI Digital Filter Design Toolkit as it has functions for creating filters, reading filters from files, and for generating LabVIEW FPGA code.  Information regarding this tookit can be found at:
    http://www.ni.com/toolkits/df_design_toolkit.htm
    -Bob
    -Bob

  • USB-5133, hws file to matlab

    Hi all,
    I use USB-5133 to measure voltages from two channels simultaneously. For that I use the NI-SCOPE. The scope saves the measured data as hws-file. I need these files in Matlab but I cannot open them. What would be the simplest way to export and open this data in Matlab?
    All help is greatly appreciated!
    Joonas
    Solved!
    Go to Solution.

    Dear Colleagues,
    Sorry for answering to this entry 2 years and a half later than the last comment, but my doubt is alligned with what you have been talking about. (Of course, if you consider that I should open a new line in the forum, just tell me, please.)
    I have followed all your key points to read some *.HWS files i capture with a PXI NI5124 (12 bits, 2 channels).
    I'm already able to read the data in labview and in Matlab, BUT I found a problem with the scaling of the data i have stored:
    I took the signals simultaneously (2 channels) from -1V to +1V, but all the data have been stored in INTEGER number like:
    16 112 32 128 96 64 80 80 0 32 -48 16 64 48 48 0 16 48 80 16 48 48 16 -16 16 -48 -80 -48 -96 -96 -80 16 -64 -16 -16 48 64 64 144 176 160 128 160 176 160 128 96 32 -16 -64 -160 -128 -160 -160 -176 -176 -192 -96 -32 0 48 48 112 80 192 192 192 192 208 160 64 144 32 -160 16 -64 -128 -256 -176 -128 -192 -208 -144 -48 -128 -256 112 320 16
    These are only few samples, as I took 1.000.000 Samples @ 50 MSamples / s per file. I had some values up to +32000 and down to -29000, aprox.
    I was surprised as i should had values like 0.001, 0.002 -0.2, -0.00005, etc.
    The point is that I have found the scaling coefficients that are applied for each channel:
    CH0 a:-1,143859 and b:3,2599724
    CH1 a:-1,427364 and b:1,6671666
    But I don't know how to scale the values i have registered down to the real ones. And I haven't found how this scaling works on the HWS files.
    Thank you very in advance. I wold appreciate any help or int...
    Best regards,

  • Can you interface MATLAB with Labview??

    Can Labview activate m-files on MATLAB (while the MATLAB is running obviously) and can the two programs exchange data?
    if so how is this done??
    Thanks for everything!

    I encourage you to search NI's Developer Zone for "MATLAB" - there are numerous resources available, including some threads in these forums.
    On Windows, LabVIEW offers the MATLAB script node. It works much like the LabVIEW Formula Node, except that you paste an m-script into the node. LabVIEW passes the script to MATLAB through MATLAB's ActiveX interface. MATLAB does the processing, and gives the results back to LabVIEW. You can then use the results in your VI.
    Steven H.

  • I am trying to integrate simulink model (.mdl) file with SIT of Labview for RCP and HIL purpose. I am using Labview 8.6, Simulink 6.6 with RTW 6.6 and RTW embedded coder 4.6 ,Visual C Express 2008 and Visual C++ Express 2008.

    I am trying to integrate simulink model (.mdl) file with SIT of Labview for RCP and HIL purpose. I am using Labview 8.6, Simulink 6.6 with RTW 6.6 and RTW embedded coder 4.6 ,Visual C Express 2008 and Visual C++ Express 2008. I have selected system target file as nidll.tlc,make command as make_rtw and template nidll_vs.tmf. When I try to generate .dll file I get the following error.
    Attachments:
    SITProblem.JPG ‏101 KB

    Hi,
    No . I could not solve the issue. Presently we are using microautobox (from Dspace)for doing the RCP.
    Himadri 

  • MATLAB and LabVIEW Communication Optimal Performance

    I have tried my own code,  searched through forums and examples to try and figure out best method to communicate between LabVIEW and MATLAB.  Most of the information I found was over a year old and I was wondering if there was a better current solution.  My goal is to work in LabVIEW to collect the data, process in MATLAB and return the results to LabVIEW.  I have encountered some difficulty in my search and before I delve even further in to one in particular, I was wondering if anybody had an optimal solution with this communication protocol or solutions to my errors encountered thus far.
    I have looked at the following methods.
    1)TCP/IP and a very good example found here: http://www.mathworks.com/matlabcentral/fileexchange/11802-matlab-tcp-ip-code-example
    When I try to adjust even the example and communicate for my own purposes I get the following errors
    Error 63 if MATLAB server not running
    Error 66 occurs if the TCP/IP connection is closed by the peer. In this case, Windows notices that no data is returned within a reasonable time, and it closes the TCP/IP connection. When LabVIEW attempts to communicate after Windows closes the connection, error 66 is the result. 
    However, the example itself works perfectly and does not get these errors
    2)Math Script Node, works but the post below states that MATLAB Node is faster.
    "computing fft of a 1024x1024 matrix ten times (attached code). Result is that Matlab node version takes 0.5s versus 1.6s for Mathscript node version."
     http://forums.ni.com/t5/LabVIEW/Why-are-mathscript-performances-much-below-matlab-s/m-p/2369760/high...
    3) MATLAB Node, which states it uses ActiveX Technology seemingly works well, but loses time for data transfer.
    4) Trying to use the ActiveX functions or if there is other Automation potential.
    5)Other solutions that I have not found that might be better suited.
    Thank you for any help or suggestions in advance. 

    Barp and Mikeporter,
    Thank you for your assistance:
    The reason I need to do the processing in matlab is as you mentioned the processing script is coming from another person who has already developed it in matlab.  I almost have to treat it as a black box.
    The TCP/IP method was interesting is that none of the errors show up when I run the example but if I try to modify it in a new VI I get the errors.
    I have attached a simple program that just has a basic butterworth low pass filter I am trying to confirm if it works in the Matlab node.  I have done other simple codes which work, and this one does not seem the implement  the appropriate filter.  The LabVIEW signal and LabVIEW filter seem to work at the default values (but not if I change sampling rate) for the Simulation of signal, Matlab signal and Matlab filter work, but the Labview signal processed in Matlab is not working...
    Ideally it would be bandpass filtered (0.1-30) at sampling rate of 256 Hz and further processed from there, but I can't even seem to get low pass to work in the matlab to labview communication.
    Any help would be greatly appreciated.  Once I have that working I will have more of an idea of the constraints of the actual processing Matlab Code I will be using.
    Thank you again.
    -cj18
    Attachments:
    labview_matlab_filter.vi ‏70 KB

  • Open CSV files in Excel through labview

       Dear,
    Am not famillar with *.csv files but I would like to know if it's possible to : open a CSV files in excel through labview.
    I can't used ActiveX for my application. This application is on Labview 8.2
    Regards
      Massif

    Hi Massif,
    a .csv file is a spreadsheet file, so use the "open spreadsheet file" VI.
    Cheers
    Edit:
    Dang, I'm always 30seconds behind you smercurrio!
    Message Edited by lmtis on 04-22-2008 10:27 AM
    Jim
    LV 2013
    Attachments:
    csv.png ‏2 KB

  • File permission error in LabVIEW, but what file?

    I am in the process of smoothing out the wrinkles in a large LabVIEW program that I've converted from LV 7.0 to LV 2011SP1.  I've also moved from WinXP to Windows 7.  I get why there are file permission errors and I understand what the issues are in regard to moving from XP to 7.  What I would really like, is for the error message to tell me WHAT file is having the issue.  There are entirely too many file accesses in this program, I am not the originator, and it's been painful.  A more explicit error message, a log file, or some other cool trick to find what file is having the issue would be super.  While I'm asking for stuff, a call stack or at least the name of the VI this code calls would be wonderful, as nothing at all calls New File directly.
    Certified LabVIEW Developer
    NI-VLM Administrator

    How are you currently handling the error?  The file you tried to access should be part of the string in the error cluster.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to Read TDMS Files in Matlab in OSX

    Using the example found on the NI website (http://digital.ni.com/public.nsf/allkb/0EEADA99DC​7D00A4862572E30037C3A2), I am able to read my TDMS files into Matlab when using a PC.  However, when I try to read them on my Mac, I receive an error:
    ??? There was an error loading the library "/Applications/MATLAB75/work/TDMS_files/dev/bin/ni​libddc.so"
    Error using ==> loaddefinedlibrary
    dlopen(/Applications/MATLAB75/work/TDMS_files/dev/​bin/nilibddc.so, 1): image not found
    Error in ==> read_tdms at 21
    loadlibrary(DLL_Path, H_Path);
     My best guess for this error is the fact that Matlab operates through a Linux interface on Mac, which I found will open the file type .so and not .dll for this type of library.  Is there some way to get around this in OSX and get it to read the .dll files?  Or is there some way to get the libraries as .so files instead of .dll files?
    Thanks for any help!
    -Shelby

    Shelby,
    You may wish to look at a Matlab script another user wrote since they were having issues with NI's matlab support:
    http://forums.ni.com/ni/board/message?board.id=170​&view=by_date_ascending&message.id=318487#M318487
    The script supposedly converts TDMS files directly in Matlab with no use of NI generated external DLLs.  He was having issues because the NI tools hadn't been updated for the new version of Matlab.

  • A problem was encountered with one of the files in TestStand\AdapterSupport\LabVIEW directory

    When looking at the module for a LabVIEW VI being called from TestStand, I get the following message:
    A problem was encountered with one of the files in TestStand\AdapterSupport\LabVIEW directory.  Please reinstall it or repair it.
    I made the mistake of cleaning up C: in my computer.  Cleaning C:\National Instruments Downloads
    Why would someone put bits of applications or modules, etc in such a directory?
    I am not too crazy about restoring 11GB back into that folder.  That's just insane!
    Has anyone encountered this before?  Any "easy" solutions? apart from re-installing TS...
    Side note:  I did not touch anything in the \Program Files|National Instruments\TestStand\AdapterSupport\LabVIEW
    Solved!
    Go to Solution.

    Thanks PH,
    I also had that.  Fixed it. 
    I will not remove the ones in the NI downloads folder.
    I will eventually need to remap everything to the appropriate drive. 
    I partition the drives into:
    C:\     Windows and associated folders.  Mostly OS stuff
    E:\     Applications (this is where it will end up)
    F:\     Files
    G:\    Storage
    H:\    Backups
    I try to do what I normally implement in Linux.  I hate sharing the OS with everything else.
    Cheers,
    RayR

Maybe you are looking for