Main Content

setTestValue

Modify test values for validating data function

Since R2023a

Description

example

msys = setTestValue(vSys,t0) modifies the test time t0 used to validate the data function. The data function is reevaluated for this new value.

example

msys = setTestValue(vSys,t0,p0) also modifies the test parameters p0 used to validate the data function of LPV models.

Examples

collapse all

This example shows how to modify the test values for the data function of an LPV model.

For this example, consider dataFcnMaglev.m data function which describes the dynamics of a magnetic levitation system.

Create the LPV model with default test values.

vsys = lpvss('h',@dataFcnMaglev);

This model is not valid for height h = 0 as the A matrix is not finite for (t,h) = (0,0).

A = vsys.DataFunction(0,0)
A = 2×2

     0     1
   Inf     0

Modify the test value to h = 1.

h0 = 1;
msys = setTestValue(vsys,0,h0)
Continuous-time state-space LPV model with 1 outputs, 1 inputs, 2 states, and 1 parameters.
Model Properties
A = vsys.DataFunction(0,h0)
A = 2×2

         0    1.0000
   19.6200         0

Data function code.

type dataFcnMaglev.m
function [A,B,C,D,E,dx0,x0,u0,y0,Delays] = dataFcnMaglev(~,p)
% MAGLEV example:
% x = [h ; dh/dt]
% p=hbar (equilibrium height)
mb = 0.02; % kg
g = 9.81;
alpha = 2.4832e-5;
A = [0 1;2*g/p 0];
B = [0 ; -2*sqrt(g*alpha/mb)/p];
C = [1 0];  % h
D = 0;
E = [];
dx0 = [];
x0 = [p;0];
u0 = sqrt(mb*g/alpha)*p;  % ibar
y0 = p;                   % y = h = hbar + (h-hbar)
Delays = [];

Input Arguments

collapse all

LTV or LPV model, specified as an ltvss or lpvss object, respectively.

Specify a model whose data function must be validated at a different time. The software only lets you combine models with shared parameters when their data function is validated at the same value for that parameter.

New test value for time, specified as a scalar.

New test value for parameter, specified as a vector with length equal to the number of parameters.

Output Arguments

collapse all

LTV or LPV model with modified test values for data function, returned as an ltvss object or lpvss object, respectively.

Version History

Introduced in R2023a