## Numerical Integration -Matlab

## Numerical Integration -Matlab

(OP)

Does anybody know how to numerically integrate the following formula in Matlab?

“The most successful people in life are the ones who ask questions. They’re always learning. They’re always growing. They’re always pushing.” Robert Kiyosaki

## RE: Numerical Integration -Matlab

You need an initial condition for theta and a time history for P, which appears to be the independent variable. The brute force approach then looks like this.

%set up initial conditions

m=

g=

P= %a single column vecotr

theta0=

dt=

%and so on

%get some vectors preallocated

L=size(P)

t=0*P

x=t;

y=t

theta=t;

%and so on

%initialise t=0 conditions into first row

theta(1)=theta0;

%and so on

%main loop

for ii=2:L

t(ii)=t(ii-1)+dt;

%work out accel using previous time step and new P

%work out vel using previous time step and new acc

%work out theta using previous time step and new vel

%tidy up

end

Cheers

Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

## RE: Numerical Integration -Matlab

I’d much rather use excel. I know how to use Newmarks method for a certain second order differential equation, but it’s unclear to me if the same variables can be used for this equation.

Would you be willing to help me get started with this in excel?

“The most successful people in life are the ones who ask questions. They’re always learning. They’re always growing. They’re always pushing.” Robert Kiyosaki

## RE: Numerical Integration -Matlab

Cheers

Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

## RE: Numerical Integration -Matlab

“The most successful people in life are the ones who ask questions. They’re always learning. They’re always growing. They’re always pushing.” Robert Kiyosaki

## RE: Numerical Integration -Matlab

Cheers

Greg Locock

New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?

## RE: Numerical Integration -Matlab

For my problem above the resisting force is function of theta yet most numerical method examples I've seen have had the "k" term as a constant.

“The most successful people in life are the ones who ask questions. They’re always learning. They’re always growing. They’re always pushing.” Robert Kiyosaki

## RE: Numerical Integration -Matlab

Greg Locock

## RE: Numerical Integration -Matlab

## RE: Numerical Integration -Matlab

Greg Locock

## RE: Numerical Integration -Matlab

How I'm seeing this really is is a series of algebraic equations.

At step t=0: F=(some value), acceleration=0, theta=0 --> instability occurs

At step t=0.001: correct for instability, what progresses first to facilitate the solving of the rest of the variables?

I must have to assume the progression of either rotation, or rotational acceleration to get to step 2, since there are two unknowns?

## RE: Numerical Integration -Matlab

Greg Locock

## RE: Numerical Integration -Matlab

Maybe this is why Newmarks terms are necessary

## RE: Numerical Integration -Matlab

transient electromagnetic and transient thermal applications.

The approach dates back 50 years when analog computers had patch panels .

Users would draw a block diagram just by inspection of the ODE and its auxiliaries, ready to patch it up.

Analog computers are extinct, but I found the block diagram method to be quick and useful.

I also use circuit simulators and FEM suite , but found some applications are better solved using this method.

The hardware is replaced by coding the function blocks (in this example,Python3).

Although the old analog computers could not solve a Partial DE (PDE),

I have used a similar method to solve PDE by equating (for example) a spatial finite differencing to an integrator in time.

The screenshots below are shown just as an example of the method using an approximate interpretation of MegaStructure's diagram.

Constants and initial conditions are not correct.

Block Diagram from ODE and aux functions.:

https://app.box.com/s/logqmbimuykbr9racaavw2ab39uf...

Python:

https://app.box.com/s/t64dqh1zjd2rwro1rghywsry0mnp...

Results:

https://app.box.com/s/mtk0fdntu51vvzti0y38hryiadak...