Main Content

预习

Class:matlab.io.datastore。SimulationDatastore
包裹:matlab.io.datastore

Return subset of data from datastore

句法

数据=预览(DST)

描述

data= preview(dstreturns a subset of data from datastore (matlab.io.datastore。SimulationDatastore目的)dstwithout changing its current read position.预习仅返回数据存储中数据的前十个示例(时间步)。使用此方法快速检查并验证数据是否如您预期出现。

输入参数

展开全部

输入数据存储,,,,specified as amatlab.io.datastore。SimulationDatastore目的。To create aSimulationDatastore对象,请参阅matlab.io.datastore。SimulationDatastore

输出参数

展开全部

Subset of data, returned as a时间表目的。有关信息时间表, 看时间表

例子

展开全部

此示例显示了如何通过与A相互作用来检查模拟中的大数据并检查和分析该数据的部分matlab.io.datastore。SimulationDatastore目的。

来自模型的大数据

打开示例模型sldemo_fuelsys

open_system('sldemo_fuelsys'

选择Configuration Parameters > Data Import/Export > Log Dataset data to file

set_param('sldemo_fuelsys',,,,'LoggingToFile',,,,'上'

模拟模型。

sim('sldemo_fuelsys'

垫子出门出现在您当前的文件夹中。该文件包含记录信号的数据,例如fuel(位于模型的根级别)。

在命令提示下,创建一个DatasetRef目的that refers to the logging variable by name,sldemo_fuelsys_output

dsref = 金宝appsimulink.simulationdata.datasetref('out.mat',,,,'sldemo_fuelsys_output');

Preview Big Data

Use curly braces ({and})提取信号元件fuel,这是第十个元素DSREF, 作为一个Simulink.SimulationData.Signal目的that contains aSimulationDatastore目的。

SimDataSig = DSRef{10};

To more easily interact with theSimulationDatastore位于财产的theSignal目的,,,,store a handle in a variable namedDstore

Dstore= SimDataSig.Values;

使用预习检查前五个记录数据样本的方法fuel信号。

预览(DSTORE)
ans = 10x1 timetable Time Data ______________ ______ 0 sec 1.209 0.00056199 sec 1.209 0.0033719 sec 1.209 0.01 sec 1.1729 0.02 sec 1.1409 0.03 sec 1.1124 0.04 sec 1.0873 0.05 sec 1.0652 0.055328 sec 1.0652 0.055328 sec 1.0652

检查具体样本

检查第603个记录样品fuel数据。

设置读取尺寸财产的Dstore对于考虑内存资源的数字,您的计算机可以忍受。例如,设置读取尺寸200

dstore.ReadSize = 200;

Read from the datastore three times. Each read operation advances the reading position by 200 samples.

阅读(dstore);阅读(dstore);阅读(dstore);

现在您非常接近603个样本,设置读取尺寸达到较小的数字。例如,设置读取尺寸5

dstore.ReadSize = 5;

再次从数据存储中读取。

read(DStore)
ANS = 5x1时间表时间数据________ ______ 5.79 SEC 1.6097 5.8 SEC 1.6136 5.81 SEC 1.6003 5.82 SEC 1.5904 5.83 SEC 1.5832

The third sample of read data is the 603rd sample in the datastore.

检查早期样本

检查已记录的第403样品fuel数据。由于以前的读取操作,数据存储现在从第606个示例开始读取,因此您必须重置数据存储。然后,您可以从第一个示例阅读到第403个样本。

使用重置重置方法Dstore

重置(DSTORE);

读取尺寸200again.

dstore.ReadSize = 200;

Read from the datastore twice to advance the read position to the 401st sample.

阅读(dstore);阅读(dstore);

读取尺寸5again.

dstore.ReadSize = 5;

Read from the datastore.

read(DStore)
ANS = 5x1时间表时间数据________ _______ 3.85秒0.999 3.86 SEC 0.99219 3.87 SEC 0.98538 3.88 SEC 0.97858 3.89 SEC 0.97179

Extract Multiple Samples

Extract samples 1001 through 1020 (a total of 20 samples).

Reset the datastore.

重置(DStore)

前进到1001。

dstore.ReadSize = 200;为了i = 1:5读(dstore);结尾

准备从数据存储中提取20个样本。

Dstore。读取尺寸= 20;

Extract samples 1001 through 1020. Store the extracted data in a variable named目标样本

targetsamples =读(DSTORE)
targetSamples = 20x1 timetable Time Data ________ ______ 9.7 sec 1.5828 9.71 sec 1.5733 9.72 sec 1.5664 9.73 sec 1.5614 9.74 sec 1.5579 9.75 sec 1.5553 9.76 sec 1.5703 9.77 sec 1.582 9.78 sec 1.5913 9.79 sec 1.5988 9.8 sec 1.605 9.81 sec 1.6101 9.82 sec 1.6145 9.83 sec 1.61849.84 SEC 1.6049 9.85 SEC 1.595 9.86 SEC 1.5877 9.87 SEC 1.5824 9.88 SEC 1.5785 9.89 SEC 1.5757

在数据存储中查找数据的最大值

Reset the datastore.

重置(DStore)

写一个while循环,使用hasdatamethod, to incrementally analyze the data in chunks of 200 samples.

dstore.ReadSize = 200;RunningMax = [];whilehasdata(dstore)tt = read(dstore);rawchunk = tt.data;runningmax = max([rawchunk; runningmax]);结尾

现在,变量RunningMax将最大值存储在整个数据存储中。

RunningMax
RunningMax = 1.6423

版本历史记录

在R2017A中引入

也可以看看