Interfacing with MATLAB

Altair Forum User
Altair Forum User
Altair Employee
edited October 2020 in Community Q&A
 

Submitted by shaabanyusuf on Fri, 07/20/2012 - 16:28 

Hi,

I have just installed VisSim. I have tried to run simulations with MATLAB interface but it keeps giving me the error 'Simulation aboted at 0 simulated seconds 21 real seconds'. I tried to run the examples in VisSim but without success.

Thank you

Tagged:

Answers

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by a_a on Fri, 07/20/2012 - 19:48.

    Hi. The fact that the exmple got aborted does not sound good. But.. Why do you need Matlab if you use VisSim? What is your application?

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by shaabanyusuf on Fri, 07/20/2012 - 19:54.

    Hi,

    I will like to get variables from matlab and write variable to matlab workspace. My application is in control systems.

    Yusuf

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by ATHIESH on Sun, 12/29/2013 - 20:07.

    you can import and export variables from Matlab i.e., from .mat file using Signal producer-->import and signal consumer--> export blocks u can export upto 16 variables in a single .mat file

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by ATHIESH on Sun, 12/29/2013 - 20:08.

    you can import and export variables from Matlab i.e., from .mat file using Signal producer-->import and signal consumer--> export blocks u can export upto 16 variables in a single .mat file

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited November 2020

    Submitted by Ric on Tue, 01/27/2015 - 09:29.

    You can use the VisSim 'Matlab Expression' block located in 'Blocks/Matlab Interface' to communicate data from VisSim to MATLAB, process the data in MATLAB, and return the processed data to VisSim. I'm attaching an example .vsm that calls an .m file, assuming you have a copy of MATLAB on your computer and you create the VisSimMatLabDemo.m file (shown below) and place the .m file in the same folder as the .vsm file is located, you should be able to run the .vsm file and see the correct results. I have seen the need to re-launch both VisSim and MATLAB in some situations where a change is made to the .m file in order for the change to take effect.

    function yvec = VisSimMatLabDemo(xvec) %Called from 'VisSimMatLabDemo.vsm'

    % Input vector, xvec % xvec(1) = iFirstPass = 1/0 = first pass/ else % xvec(2) = input1 % xvec(3) = input2 % % Output vector, yvec % yvec(1) = output1 % yvec(2) = output2 % %unload Input vector into local variables iFirstPass = xvec(1); u1 = xvec(2); u2 = xvec(3);

    k1 = 1.; k2 = 2.;

    if iFirstPass == 1 % Include any initialization logic here... yvec(1) = 0; yvec(2) = 0; else yvec(1) = k1u1; yvec(2) = k2u2; end

    Unable to find an attachment - read this blog

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by Gwizz on Thu, 03/31/2016 - 00:43.

    When I start VisSim 9.0 on my Windows 7 PC, I get an error message that reads 'Matlab interface error 126. The specified module could not be found.' I have Matlab 2016a and I would like to do some work in VisSim using Matlab expressions. VisSim doesn't communicate with my Matlab install. What should I do or re-install?

    Gary Scott Schneider Electric

  • Altair Forum User
    Altair Forum User
    Altair Employee
    edited June 2016

    Submitted by a_a on Wed, 04/13/2016 - 21:13.

    Due to license limitations we cannot test the interface with the latest Matlab builds here at our office. VisSim is a 32 bit application, so if you have a 64 bit Windows then you need both 32 and 64 bit Matlabs. As I can recall, the directory structure of Matlab looks something like ..\bin\win32 and/or ..bin\win64 The folders may have different names but 32 and 64 are presented. VisSim Matlab interface dll is named vsmML.dll It must be placed in the same folder where Matlab dll-s (libmx.dll and libeng.dll) are and it needs to be a 32 bit folder. Then, in VisSim, the path for vsmML.dll in Edit > Preferences > Addons must match that directory.

    If you send a message to support@vissol.com, then I'll read it there and get your e-mail.