Turn on thread page Beta
    • Thread Starter
    Offline

    2
    ReputationRep:
    Good evening all.

    I'm running a simulation on matlab of a car travelling. Its all ok and works perfect. Mass of the car is constant.

    I want to change to the mass of the car ( or in particular the mass of the passengers ) aswell. But run the same same initially sim. How do I do this:

    So in matlab ive seen in the tutorials that the matrix can work like a notebook, so if mass was 1 to 100. There would be 100 simulations all put together?

    How do I go about doing this? Do anyone know what this is called and where to go for info?
    • TSR Support Team
    Offline

    21
    ReputationRep:
    TSR Support Team
    (Original post by JohnNash2)
    Good evening all.

    I'm running a simulation on matlab of a car travelling. Its all ok and works perfect. Mass of the car is constant.

    I want to change to the mass of the car ( or in particular the mass of the passengers ) aswell. But run the same same initially sim. How do I do this:

    So in matlab ive seen in the tutorials that the matrix can work like a notebook, so if mass was 1 to 100. There would be 100 simulations all put together?

    How do I go about doing this? Do anyone know what this is called and where to go for info?
    I'm not sure I really understand what you're asking. You've got a bunch of code and you want to ruin it for different masses? I'm guessing that's not what you're asking because that's relatively straightforward. Could you clarify?
    • Thread Starter
    Offline

    2
    ReputationRep:
    Thanks for replying.

    Basically I want to run the same sim for mass 100-300kg and see how that effects the final speed. So I want to plot a graph of Mass against Vend.

    Is it really simple (im an amateur)? How do you do it? What the process called?

    Thanks in advance
    • TSR Support Team
    Offline

    21
    ReputationRep:
    TSR Support Team
    (Original post by JohnNash2)
    Thanks for replying.

    Basically I want to run the same sim for mass 100-300kg and see how that effects the final speed. So I want to plot a graph of Mass against Vend.

    Is it really simple (im an amateur)? How do you do it? What the process called?

    Thanks in advance
    I'd suggest that you turn your model into a function (with mass as its input, and potentially other constants depending on how flexible you want your function to be) and then make a simple loop where in each iteration you execute the function for the new mass increment. And then just plot f(m) versus m. Does that make sense?
    • Thread Starter
    Offline

    2
    ReputationRep:
    (Original post by Plagioclase)
    I'd suggest that you turn your model into a function (with mass as its input, and potentially other constants depending on how flexible you want your function to be) and then make a simple loop where in each iteration you execute the function for the new mass increment. And then just plot f(m) versus m. Does that make sense?
    I dont really understand that. Is there no way to stick another for loop
    around the original loops and then plot that way. Thats how I've been working. What is the matlab term for the 2 loop solution so i can go and research?
    • TSR Support Team
    Offline

    21
    ReputationRep:
    TSR Support Team
    (Original post by JohnNash2)
    I dont really understand that. Is there no way to stick another for loop
    around the original loops and then plot that way. Thats how I've been working. What is the matlab term for the 2 loop solution so i can go and research?
    Yes you definitely could just use nested for-loops (i.e. use the mass as your 'for' in the big loop, and then put the entire code into that loop), it's just a bit neater to use a function.
    • Thread Starter
    Offline

    2
    ReputationRep:
    Thanks for your help btw. I get the loops part

    for m=100:1:300
    for xXXXXX
    XXX
    XXX
    XXX
    XXX
    end
    end

    With respect to the m part how do i create the multidimensional array or matrix. What do I need to put in? I cant find any examples of code on the net?
    • TSR Support Team
    Offline

    21
    ReputationRep:
    TSR Support Team
    (Original post by JohnNash2)
    Thanks for your help btw. I get the loops part

    for m=100:1:300
    for xXXXXX
    XXX
    XXX
    XXX
    XXX
    end
    end

    With respect to the m part how do i create the multidimensional array or matrix. What do I need to put in? I cant find any examples of code on the net?
    Sorry, I'm not really sure what you're asking? If you want to initialise an arbitrary array, try using the ones() or zeros() function.
 
 
 
Reply
Submit reply
Turn on thread page Beta
Updated: February 16, 2018

University open days

  1. Norwich University of the Arts
    Postgraduate Open Days Postgraduate
    Thu, 19 Jul '18
  2. University of Sunderland
    Postgraduate Open Day Postgraduate
    Thu, 19 Jul '18
  3. Plymouth College of Art
    All MA Programmes Postgraduate
    Thu, 19 Jul '18
Poll
How are you feeling in the run-up to Results Day 2018?
Useful resources

Make your revision easier

Maths

Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

Equations

How to use LaTex

Writing equations the easy way

Student revising

Study habits of A* students

Top tips from students who have already aced their exams

Study Planner

Create your own Study Planner

Never miss a deadline again

Polling station sign

Thinking about a maths degree?

Chat with other maths applicants

Can you help? Study help unanswered threads

Groups associated with this forum:

View associated groups

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Write a reply...
Reply
Hide
Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.