JohnNash2
Badges: 2
Rep:
?
#1
Report Thread starter 2 years ago
#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
reply
Plagioclase
Badges: 21
Rep:
?
#2
Report 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
reply
JohnNash2
Badges: 2
Rep:
?
#3
Report Thread starter 2 years ago
#3
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
0
reply
Plagioclase
Badges: 21
Rep:
?
#4
Report 2 years ago
#4
(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?
0
reply
JohnNash2
Badges: 2
Rep:
?
#5
Report Thread starter 2 years ago
#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
reply
Plagioclase
Badges: 21
Rep:
?
#6
Report 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
reply
JohnNash2
Badges: 2
Rep:
?
#7
Report Thread starter 2 years ago
#7
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?
0
reply
Plagioclase
Badges: 21
Rep:
?
#8
Report 2 years ago
#8
(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.
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

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

Personalise

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%

Watched Threads

View All