tnew — New data table used to create rm (default) | table

New data including the values of the response variables and
the between-subject factors used as predictors in the repeated measures
model, rm, specified as a table. tnew must
contain all of the between-subject factors used to create rm.

Random response values random generates, returned as an n-by-r matrix,
where n is the number of rows in tnew,
and r is the number of repeated measures in rm.

The column vector speciesconsists of iris
flowers of three different species: setosa, versicolor, and virginica.
The double matrix meas consists of four types of
measurements on the flowers: the length and width of sepals and petals
in centimeters, respectively.

Store the data in a table array.

t = table(species,meas(:,1),meas(:,2),meas(:,3),meas(:,4),...'VariableNames',{'species','meas1','meas2','meas3','meas4'});
Meas = dataset([1 2 3 4]','VarNames',{'Measurements'});

Fit a repeated measures model, where the measurements
are the responses and the species is the predictor
variable.

random uses the predictor values in the original
sample data you use to fit the repeated measures model rm in
table t.

Randomly Generate Response Values Using New Data

Load the sample data.

load repeatedmeas

The table between includes the between-subject
variables age, IQ, group, gender, and eight repeated measures y1
through y8 as responses. The table within includes
the within-subject variables w1 and w2.
This is simulated data.

Fit a repeated measures model, where the repeated measures y1
through y8 are the responses, and age, IQ, group,
gender, and the group-gender interaction are the predictor variables.
Also specify the within-subject design matrix.

rm = fitrm(between,'y1-y8 ~ Group*Gender + Age + IQ','WithinDesign',within);

Define a table with new values for the predictor variables.

random computes ysim by
creating predicted values and adding random noise values. For each
row, the noise has a multivariate normal distribution with covariance
the same as rm.Covariance.