You are Here: Home >< Maths

# Matlab Mathematical modelling watch

1. 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?
2. (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?

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?

4. (Original post by JohnNash2)

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?

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?
5. (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?
6. (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.
7. Thanks for your help btw. I get the loops part

for m=100300
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?
8. (Original post by JohnNash2)
Thanks for your help btw. I get the loops part

for m=100300
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.

### Related university courses

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: February 16, 2018
Today on TSR

### He broke up with me because of long distance

Now I'm moving to his city

### University open days

1. Norwich University of the Arts
Thu, 19 Jul '18
2. University of Sunderland
Thu, 19 Jul '18
3. Plymouth College of Art
Thu, 19 Jul '18
Poll
Useful resources

### Maths Forum posting guidelines

Not sure where to post? Read the updated guidelines here

### How to use LaTex

Writing equations the easy way

### Study habits of A* students

Top tips from students who have already aced their exams