# Matlab Mathematical modelling

Watch
Announcements
#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?
0
2 years ago
#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?
0
#3

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?

0
2 years ago
#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?
0
#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?
0
2 years ago
#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.
0
#7
Thanks for your help btw. I get the loops part

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

for m=100 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.
0
X

new posts Back
to top
Latest
My Feed

### Oops, nobody has postedin the last few hours.

Why not re-start the conversation?

see more

### See more of what you like onThe Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

### Poll

Join the discussion

#### Are you travelling in the Uni student travel window (3-9 Dec) to go home for Christmas?

Yes (120)
28.1%
No - I have already returned home (57)
13.35%
No - I plan on travelling outside these dates (84)
19.67%
No - I'm staying at my term time address over Christmas (40)
9.37%
No - I live at home during term anyway (126)
29.51%