run matlab script from Hypermesh makro

Torben0159
Torben0159 Altair Community Member
edited November 2020 in Community Q&A

Hello,

is it possible to run a matlab script from a Hypermesh makro? What i want to do is

- setup modal analysis in Hypermesh

- run tcl makro, which executes the solver

- saving the pch file from the modal analysis

- run the matlab script (which imports the pch file and exports a txt file)

- import the txt file within the tcl script

- do some further actions....

Points 2-5 should all be done in the same makro. If it is not possible, how could you do that in another way (I dont know much about programming stuff yet)?

Best Answer

  • tinh
    tinh Altair Community Member
    edited November 2020 Answer ✓

    Hi,

    to run matlab script from hypermesh, you should write the script to a *.m file, and call matlab.exe with that *.m file

     

    set matlab "C:/path/to/matlab.exe"

    set matfile "C:/path/to/script.m"

    set matscript {

           ... do matlab calculations

    }

    set fpt [open $matfile w]

    fconfigure $fpt -encoding utf-8

    puts $fpt $matscript

    close $fpt

     

    exec $matlab -r [string map {/ \\\\} $matScript]

     

Answers

  • Adriano Koga_20259
    Adriano Koga_20259 New Altair Community Member
    edited November 2020

    you can use the command 'exec'. Take a look at Google for more examples.

    Also you could use Compose to do this taks, as it already has a lot of CAE Readers implemented.

     

    image

  • tinh
    tinh Altair Community Member
    edited November 2020 Answer ✓

    Hi,

    to run matlab script from hypermesh, you should write the script to a *.m file, and call matlab.exe with that *.m file

     

    set matlab "C:/path/to/matlab.exe"

    set matfile "C:/path/to/script.m"

    set matscript {

           ... do matlab calculations

    }

    set fpt [open $matfile w]

    fconfigure $fpt -encoding utf-8

    puts $fpt $matscript

    close $fpt

     

    exec $matlab -r [string map {/ \\\\} $matScript]