Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Identifying a variable in a for loop

3 visualizaciones (últimos 30 días)
Aaron Ridall
Aaron Ridall el 17 de Abr. de 2020
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
I'm trying to model the two dimensional motion of particles and I have the velocity data of the particles in the x- and y-directions. However, I am trying to use a for loop to move the particles through the geographic space, based on their velocities. The challenge I've run into is that in my for loop I am trying to use the equation x(i) = u(i-1)*dt, where x(i) is the current x-position and u is the x-velocity, and u is known at each x- and y-location. I want to be able to code that u(i) = u at x(i), referring to the data that i inported into matlab, but I'm unfamiliar with how to write that code.
I've attached the excel file here for reference. The x-position is long_E in the file, and the x-velocities are ve. The time series information is also included in the excel file.
Thanks for any suggestions you can offer. I'm still really new to using matlab and to coding in general.
  3 comentarios
Aaron Ridall
Aaron Ridall el 17 de Abr. de 2020
Hi, Muhammad. What I want to be able to do is run the forloop so that the code will assess the x and y position the particle is at in the timestep and then use the appropriate u-value (ve in the excel) for that x,y position and the time. U is a velocity, so if I multiply u by dt, then it will generate a distance the particle has moved in the horizontal x-direction and the change in x-direction (along with the change in y-position that will work in a similar way) will represent a new value for the velocities (u and v) that I should be using for the next time step.
Mehmed Saad
Mehmed Saad el 18 de Abr. de 2020
and you have to calculate dt from t ? taking difference between current and previous time
if yes, then take this for example
see the 2nd row of your data
x = -80.3780
u = -0.1801
t = datetime('01-Jan-2015 06:00:00')
dt = 21600; %seconds as 01-Jan-2015 00:00:00 - 01-Jan-2015 06:00:00 = 6Hrs
u_into_dt = u*dt
u_into_dt =
-3.8902e+03
I dont think this is right
can you give an example like that so that i can understand what you are trying to do

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by