# Recursive type equation solution in simscape

1 visualización (últimos 30 días)
Asif Tanveer el 26 de Sept. de 2021
Respondida: Yifeng Tang el 27 de Jul. de 2022
Hello everybody, I am new in this community and have a related question. I have following code written in simscape. This is compiled ok as it is prepared in an existing block code. But its not working well. Infact I want to calculate fio2 and then assign its value to qo2 for the next timestep calculation. All the time i get qair = 0 and qo2 = 2.
variables (Access = private , ExternalAccess = observe)
qair = 1 % air flow
end
Parameters (ExternalAccess = observe)
fio2 = 2 %chamber o2
end
intermediates
qo2 = fio2
end
equation
fio2 == qair + qo2
end
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Respuestas (1)

Yifeng Tang el 27 de Jul. de 2022
Feels like you are trying to use Simscape like MATLAB :p, by considering how to use iterations to do the numerical integration. If I understand your intention correctly, you governing equation for this block is
or
and fio2 is just there to record the integral from last time step.
If so, you can get rid of fio2 totally and define the equation as
der(qo2) == -qair
or
qo2.der == -qair
And, add qo2 to the variable list. The initial condition can be set in the block in the variable tab.
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

Iniciar sesión para comentar.

### Categorías

Más información sobre Foundation and Custom Domains en Help Center y File Exchange.

R2021b

### Community Treasure Hunt

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

Start Hunting!

Translated by