Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

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

Options
  • 29-11-2010 5:52pm
    #1
    Registered Users 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