## Simple for loop question.

### Jake (view profile)

on 7 Dec 2012

I am wanting to write a for loop for 2 differential equations.

```For 0<x<5 dadb = (2*x)
```

How would I code this?

Cheers

Walter Roberson

### Walter Roberson (view profile)

on 7 Dec 2012

Differential equations? So dadb means "the derivative of a with respect to b" ? But the value you give is in terms of a third variable, x ??

Jake

### Jake (view profile)

on 9 Dec 2012

Sorry i will re-write that...

```For 0<x<5 dz/dx = (2*x)
For 5<x<10 dz/dx = (3*x)
```
Jan Simon

### Jan Simon (view profile)

on 9 Dec 2012

Are you sure that you mean a FOR-loop? Look at "doc for" and "help for", if this really matches your needs.

## Products

No products are associated with this question.

### Rick Rosson (view profile)

on 9 Dec 2012
Edited by Rick Rosson

### Rick Rosson (view profile)

on 9 Dec 2012
```   dx = 0.01;
x = (0:dx:10-dx)';```
`   idx = (x < 5);`
```   C = ...
D = ...```
`   z = ( C + x.^2 / 2 ) .* idx   +   ( D + x.^3 / 3 ) .* ( 1 - idx ) ;`

You will need to specify values for the constant C and D based on the initial value of z and the continuity condition at x = 5.

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test