({{, (RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])[{(Subscript[v, 1]),(Subscript[v, 2]),…}]
creates a (RefLink[SystemModel, paclet:ref/SystemModel]) generating a signal of values (Subscript[v, i]). }, {, (RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])[{{(Subscript[t, 1]),(Subscript[v, 1])},…}]
creates a model for the time-value pairs {(Subscript[t, i]),(Subscript[v, i])}.}, {, (RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])[obj]
creates a model for the (RefLink[TimeSeries, paclet:ref/TimeSeries]) or (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) obj. }, {, (RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])[fun,tmin,tmax]
creates a model with samples from the function fun between tmin and tmax.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel]) returns (RefLink[SystemModel, paclet:ref/SystemModel])[…].

(RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])["NewModel",…] gives the created model the name "NewModel".

(RefLink[CreateDataSystemModel, paclet:ref/CreateDataSystemModel])["PackageA.NewModel"] inserts "NewModel" into "PackageA".

The following options can be given:

Default values of (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) according to input:

For a list of values (Subscript[v, i]), (RefLink[SamplingPeriod, paclet:ref/SamplingPeriod]) defaults to 1.

Sample points in (RefLink[TimeSeries, paclet:ref/TimeSeries]) and (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) are preserved.

OpenersPrimaryExamplesSection(Spacer1)Examples  (28)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Create a model from a list of time-value pairs:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

model=CreateDataSystemModel[data]

Simulate and plot the output of the data model:

sim=SystemModelSimulate[model,10]

SystemModelPlot[sim,"y[1]"]

Create a model from a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[{{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}}]

model=CreateDataSystemModel[ts];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Create a data model of a sampled function between 0 and 10 seconds:

model=CreateDataSystemModel[Sin,0,10];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSection1(Spacer1)Scope  (15)

OpenersExampleSubsection0(Spacer1)Value Lists  (4)

Create a data model from a list of values:

data={6,9,1,9,7,6,1,8,0,2,9};

model=CreateDataSystemModel[data];

The sample interval is assumed to be 1 second:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Specify a custom sampling period:

data={6,9,1,9,7,6,1,8,0,2,9};

model=CreateDataSystemModel[data,SamplingPeriod->0.1];

Simulate for 1 second and plot:

sim=SystemModelSimulate[model,1];
SystemModelPlot[sim,"y[1]"]

Use a custom (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]):

data={6,9,1,9,7,6,1,8,0,2,9};

model=CreateDataSystemModel[data,InterpolationOrder->0];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

(RefLink[SparseArray, paclet:ref/SparseArray]) is interpreted as the corresponding (RefLink[Normal, paclet:ref/Normal]) array:

s=SparseArray[{{1}->1,{2}->3,{5}->2,{7}->1}];

model=CreateDataSystemModel[s];

The sample interval is assumed to be 1 second:

sim=SystemModelSimulate[model,7];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSubsection1(Spacer1)Time-Value Pairs  (3)

Create a model from a list of time-value pairs:

data={{0,6},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

model=CreateDataSystemModel[data];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Use a custom (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]):

data={{0,6},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

model=CreateDataSystemModel[data,InterpolationOrder->0];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Create data with multiple values for each time point:

data={{0,8,4},{1,5,2},{2,9,6},{3,10,2},{4,4,1},{5,0,4},{6,6,8},{7,3,6},{8,1,3},{9,0,1},{10,6,1}};

model=CreateDataSystemModel[data];

Simulate and plot the two output curves:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,{"y[1]","y[2]"}]

OpenersExampleSubsection2(Spacer1)TimeSeries  (3)

Create a data model from a (RefLink[TimeSeries, paclet:ref/TimeSeries]):

ts=TimeSeries[{{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}}]

model=CreateDataSystemModel[ts];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

The (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) from the (RefLink[TimeSeries, paclet:ref/TimeSeries]) is preserved:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

ts=TimeSeries[data,ResamplingMethod->{"Interpolation",InterpolationOrder->0}]

model=CreateDataSystemModel[ts];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Override the (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) when creating a data model:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

ts=TimeSeries[data,ResamplingMethod->{"Interpolation",InterpolationOrder->0}]

model=CreateDataSystemModel[ts,InterpolationOrder->3];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSubsection3(Spacer1)InterpolatingFunction  (2)

Create a model from an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]):

data={{0,6},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

if=Interpolation[data];

model=CreateDataSystemModel[if];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

Resample an (RefLink[InterpolatingFunction, paclet:ref/InterpolatingFunction]) before creating the model:

data={{0,6},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

if=Interpolation[data];

model=CreateDataSystemModel[if,SamplingPeriod->2];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSubsection4(Spacer1)Functions  (3)

Create a data model of a function sampled for 10 seconds:

model=CreateDataSystemModel[Cos,0,10];

The sample points are automatically determined:

sim=SystemModelSimulate[model,10];

SystemModelPlot[sim,"y[1]"]

Choose the (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]):

model=CreateDataSystemModel[Cos,0,10,InterpolationOrder->0];

Simulate and plot 2 seconds of the data output to show the interpolation order:

sim=SystemModelSimulate[model,2];
SystemModelPlot[sim,"y[1]"]

Set the sampling period when creating the model:

model=CreateDataSystemModel[Cos,0,10,InterpolationOrder->1,SamplingPeriod->1];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSection2(Spacer1)Options  (6)

OpenersExampleSubsection5(Spacer1)InterpolationOrder  (3)

An (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) of 0 gives constant segments between samples:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6}};

model=CreateDataSystemModel[data,InterpolationOrder->0];

Simulate and plot the output:

sim=SystemModelSimulate[model,5];
SystemModelPlot[sim,"y[1]"]

An (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) of 1 gives straight lines between samples:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6}};

model=CreateDataSystemModel[data,InterpolationOrder->1];

Simulate and plot the output:

sim=SystemModelSimulate[model,5];
SystemModelPlot[sim,"y[1]"]

An (RefLink[InterpolationOrder, paclet:ref/InterpolationOrder]) of 3 gives a smooth line with a continuous derivative:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6}};

model=CreateDataSystemModel[data,InterpolationOrder->3];

Simulate and plot the output:

sim=SystemModelSimulate[model,5];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSubsection6(Spacer1)SamplingPeriod  (3)

For a list of data, (RefLink[SamplingPeriod, paclet:ref/SamplingPeriod]) determines the period between data points:

data={6,9,1,9,7,6};

model=CreateDataSystemModel[data,SamplingPeriod->2];

The output has 2-second-long linear sections between samples:

sim=SystemModelSimulate[model,10];

SystemModelPlot[sim,"y[1]"]

For a function, (RefLink[SamplingPeriod, paclet:ref/SamplingPeriod]) determines how often a function is sampled:

model1=CreateDataSystemModel[Sin,0,10,SamplingPeriod->0.5,InterpolationOrder->0];

model2=CreateDataSystemModel[Sin,0,10,SamplingPeriod->2,InterpolationOrder->0];

Simulate with sampling periods of 0.5 and 2 seconds:

sim1=SystemModelSimulate[model1,10];
sim2=SystemModelSimulate[model2,10];

Compare the output for each simulation:

SystemModelPlot[{sim1,sim2},"y[1]"]

For a (RefLink[TimeSeries, paclet:ref/TimeSeries]), (RefLink[SamplingPeriod, paclet:ref/SamplingPeriod]) resamples uniformly:

data={{0,5},{1,4},{2,2},{3,9},{4,1},{5,9},{6,4},{7,3},{8,9},{9,2},{10,0}};

ts=TimeSeries[data]

ListLinePlot[ts]

Downsample the time series when creating the data model:

model=CreateDataSystemModel[ts,SamplingPeriod->3];

Simulate and plot the output:

sim=SystemModelSimulate[model,10];
SystemModelPlot[sim,"y[1]"]

OpenersExampleSection3(Spacer1)Applications  (1)

Create a data model with noisy output for 5 seconds:

noise=CreateDataSystemModel[Function[RandomReal[100]],0,5];

Connect it to a lowpass filter:

filteredModel=ConnectSystemModelComponents[{"noise"∈noise,"filter"∈"Modelica.Blocks.Continuous.LowpassButterworth"},{"noise.y[1]"->"filter.u"}]

Simulate the filtering model:

sim=SystemModelSimulate[filteredModel,5]

Show the signal before and after filtering:

SystemModelPlot[sim,{"filter.u","filter.y"}]

OpenersExampleSection4(Spacer1)Properties & Relations  (2)

Insert created model in a package:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6}};

CreateDataSystemModel["MyPackage.DataModel",data];

CreateDataSystemModel["MyPackage.TimeSeriesModel",TimeSeries[data]];

The package contains both created models:

SystemModels["MyPackage.*"]

Export as a file for use in a "CombiTimeTable" Modelica component:

data={{0,6},{1,9},{2,1},{3,9},{4,7},{5,6},{6,1},{7,8},{8,0},{9,2},{10,9}};

Export[FileNameJoin[{$TemporaryDirectory,"data.txt"}],{"var1",data},"MCTT"]

OpenersExampleSection5(Spacer1)Possible Issues  (1)

Larger datasets in the model may lead to slower simulations:

data=Table[{t,RandomReal[10]},{t,1000}];

dataModel=CreateDataSystemModel[data];

AbsoluteTiming[SystemModelSimulate[dataModel,1000]]

Simulating with data exported using MCTT (RefLink[Export, paclet:ref/Export]) is faster:

fileModel="DocumentationExamples.Simulation.FileInput";

AbsoluteTiming[SystemModelSimulate[fileModel,1000]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[CreateSystemModel, paclet:ref/CreateSystemModel])  ▪  (RefLink[SystemModelSimulate, paclet:ref/SystemModelSimulate])  ▪  (RefLink[ConnectSystemModelComponents, paclet:ref/ConnectSystemModelComponents])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[System Model Creation, paclet:guide/SystemModelCreation])}, {▪(RefLinkPlain[System Modeling Overview, paclet:guide/SystemModelingOverview])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(Spacer1)▪(WebLink[(Spacer1)Wolfram SystemModeler Documentation, http://reference.wolfram.com/system-modeler/])}})}})