Code covered by the BSD License  

Highlights from
Biohydrodynamics Toolbox

image thumbnail
from Biohydrodynamics Toolbox by Alexandre Munnier
Tool to simulate easily the motion of moving solids or swimming robots in a potential fluid flow.

bht_controls_check page
bht_controls_check page
Biohydrodynamics Toolbox    

bht_controls_check


Allow to check user-defined controls M-Files.

Syntax 

bht_controls_check(filename,t_range,tol)
bht_controls_check(...,cont_parameters)

Description

A valid controls M-File contains functions that give the time evolving joints' angles of the articulated bodies (called the controls functions) but it contains also the expressions of the first and second derivatives of these functions. Any error in these expressions will deeply impact the bodies' motions. 
The function bht_controls_check computes numeric first and second derivatives of the controls functions given in the M-File filename, over the time interval t_range = [T(1),T(2)] and with theoretical accuracy tol, using the central difference formula. A figure is next displayed with three subplots. The first one is the plot of the controls functions. The others are the plots of the errors between the computed numeric derivatives and the user's expressions of these derivatives given in the M-File. We point out that an error larger than the theoretical one does not necessarily means that the formula is wrong. Conversely, there can be an error in the formula even if the computed error is within the theoretical one.
Add the optional input cont_parameters when the controls M-File requires a parameters array.

Example

The following command line checks the controls M-File controlsmfile which drives six articulated bodies' hinges and requiers three parameters. The controls functions are checked over the time interval [0 10] and the accuracy for the computation of the numeric derivatives is 1e-4:
>> bht_controls_check('controlsmfile',[0 10],1e-4,[1.5 -2.6 3.1])
Error order estimated: 0.0001
Max errors for dc: 9.0282e-06  1.0637e-05  1.0637e-05  1.0637e-05  1.0637e-05  1.0637e-05 -> Ok
Max errors for dttc: 5.1503e-05  6.1025e-05  6.1025e-05  6.1025e-05  6.1025e-05  6.1025e-05 -> Ok
The following figure is displayed:
Images/controls_errors.jpg

See also

controls M-File
bht_data_compile
2008 - A. Munnier and B. Pincon (Insitut Elie Cartan and INRIA Lorraine, Projet CORIDA, Nancy, France).       

Contact us at files@mathworks.com