Incremental step until condition met

Hello everyone and thank you in advance.
I don't know how arrange correctly - I guess - the sintax "while, loop, for, if".
In particular, i have a block on a surface that simulate a simple wall and in wich I apply an horizzontal acceleration.
My goal is to focus on this acceleration and the velocity at the top of the block.
So I have a control point at the top where I monitor the speed, and I'd like increment the amount of the horizontal acceleration on the block if the velocity reach 0 within (e.g) 10 seconds.
E.g.:
I start with the value "0.1" of horizontal acceleration and I see the speed on the top. If within 10s reach 0, then I "reset" the initial condition, and I restart the loop (?) with "0.2" etc.
There is a way to do so?
This is the scheme only to show my problem, but that is useless for the purpose of the question

6 comentarios

David Hill
David Hill el 25 de Feb. de 2021
I assume the initial velocity is known. Your problem is somewhat confusing since the arrows are in the same direction. You would need a negative acceleration to slow down a positive initial velocity to zero. A simple equation will solve the problem. No need to iterate.
Steven Lord
Steven Lord el 25 de Feb. de 2021
So essentially you're trying to model something like a box on a floor (or maybe a hockey puck on ice?) and you want to give the box a push every time friction with the ground causes it to stop within 10 seconds of the last push?
Francesco Rossetto
Francesco Rossetto el 25 de Feb. de 2021
Editada: Francesco Rossetto el 25 de Feb. de 2021
Since I have an acceleration, at time 0 I will have zero speed.
Being a static equilibrium, I will need enough acceleration for the block to tip over. For this reason the idea was to proceed in an iterative way, in order to find the acceleration value necessary for overturning. Of course this is a simple case and without problems I know how to solve it by hand, but obviously I will have to apply it to complex cases.
Francesco Rossetto
Francesco Rossetto el 25 de Feb. de 2021
Not exactly. I uploaded another image so maybe you understand a little better.
Anyway, imagine that this block is bound to the ground with a hinge in the lower right corner (see the second image). If I do not apply any horizontal acceleration, the block remains stationary (and the speed at the top remains zero). But if I apply the acceleration I can have two cases (equilibrium of the static and not):
1) If the acceleration is too low, then the block remains stationary (and the top speed remains zero).
2) If the acceleration is sufficient, then the block will begin to tip over and therefore the speed at the top will be non-zero.
This is why I am looking for an "automated" way to find the horizontal value sufficient for the block to overturn, ie that within 10 seconds the top of the block has a non-zero speed.
David Hill
David Hill el 25 de Feb. de 2021
This is a torque problem. To model properly you need to know the center of gravity (assume the center for uniiform density of block), dimensions of the block, and mass. You talk about applying an acceleration, but in reality you would be applying a force. The block will start moving when the torque at the top overcomes the torque being applied by the block's weight.
Francesco Rossetto
Francesco Rossetto el 26 de Feb. de 2021
Yes sure, but the point where I want to dwell is different. In fact my type of problem is not so much about the "theory" but about the "language" of the code I would like to use. I try to explain myself better. This matlab code allows me to communicate with a program (in my case it is called 3DEC), which already calculates everything, so it takes into account the center of mass, center of gravity, etc. For this reason what I wanted to do is just to know if there is a way to write what I was asking, beyond the theory behind it. So beyond my specific case, if it is possible to do what I said, and then just write something like, as I said:
1) I apply a horizontal acceleration per step: for example I start with a value "0.5"
2) I check a point and its speed (in my program is called "xvel x y z", with x y and z coordinates of the point)
3) if the speed of the point on the top "xvel xyz" is equal to zero within a time of (example) 10 seconds (in the program I use, I write it "solve time 10"), then I go back to the initial condition (1) and put a subsequent value, such as "0.6". I repeat step (2) and check the speed. I proceed like this until the speed of the point in the desired time is zero. Then I finish the loop.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Preguntada:

el 25 de Feb. de 2021

Comentada:

el 26 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by