Tuesday, December 16, 2014

running m-file from Simulink

Create Block Callbacks

You can create block callbacks interactively or programmatically.
To create block callbacks interactively:
  1. Right-click a block, and in the context menu, select Properties.
  2. In the Block Properties dialog box, select the Callback tab.
  3. Create the callback code.

To create a block callback programmatically, use the set_param command to assign MATLAB® code to the block callback parameter.
ex: 
openFcn: -> m file to run 

Monday, December 15, 2014

Register SimMechanics Link with SolidWorks

Follow this link.
http://www.mathworks.com/help/physmod/smlink/ref/linking-and-unlinking-simmechanics-link-software-with-solidworks.html?refresh=true

Software Requirements

Registration requires that the following two products be installed on your computer:
  • SolidWorks
  • Download SimMechanics Link Software

    You can download SimMechanics Link software directly from the MathWorks® website:
    1. Visit the SimMechanics Link download website athttp://www.mathworks.com/products/simmechanics/download_smlink.html.
    2. Select the software version to install.
    3. Click Submit.
    4. Save the installation files in a convenient folder.
      Do not extract the zip file.

    Install SimMechanics Link Software

    Install SimMechanics Link software from the MATLAB command line:
    1. Start MATLAB.
        Note:   You may need administrator privileges to complete the installation.
    2. At the MATLAB command line enter:
      path(path, '<installation_file_folder>')
      replacing <installation_file_folder> with the path to the folder with the installation files.
    3. At the MATLAB command line, enter:
      install_addon('<zip_file_name>.zip')
      replacing <zip_file_name> with the name of the zip file that you downloaded (e.g., smlink.r2014b.win64). The command extracts the zip archive files to the MATLAB root directory

    Register SimMechanics Link

    To register SimMechanics Link with the CAD platform:
    1. Start a new MATLAB® session.
    2. At the MATLAB command line, enter smlink_linksw.
    3. MATLAB displays a message stating that linking was successful. You can close MATLAB.

    Add SimMechanics Link to SolidWorks Menu bar

    SimMechanics Link is now registered as a SolidWorks add-in tool. To use the tool, select the tool as an active add-in:
    1. Open SolidWorks.
    2. In the menu bar, select Tools > Add-Ins.
    3. In the Add-Ins dialog box, select SimMechanics Link.
    The menu bar of the CAD platform displays a SimMechanics Link menu item.