Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

MATLAB: How do you simulate a simulink model through an m-file?

  • 29-11-2010 05:52PM
    #1
    Registered Users, Registered Users 2 Posts: 61 ✭✭


    Hey guys, can you help me with this. I am looking to get a a simulink model to run in my m-file. I know that if my simulink model is called BusAssignment then to simulate it you would use sim('BusAssignment') but the problem is that the program might not know the name of the simulink model so it needs to retrieve it. I plan on doing this using a GUI with the edit txt box tag called "simulinkname". So how do you get the name typed in the GUI (which is the name of the users simulink model) to simulate?

    Any ideas?

    Thanks!
    Regards,
    Conor


Comments

  • Hosted Moderators Posts: 7,486 ✭✭✭Red Alert


    Could you use

    input('Enter file name to simulate ','s');

    It'll ask for it on the matlab command line.



    You could also put it in a function, and call it with the name - like this:

    function runMySimulation(simFileName)
    sim(simFileName);
    end

    and call the file runMySimulation.m, then try running it like this:

    runMySimulation simFileName


Advertisement