预习
Class:matlab.io.datastore。SimulationDatastore
包裹:matlab.io.datastore
Return subset of data from datastore
句法
数据=预览(DST)
描述
returns a subset of data from datastore (data
= preview(dst
)matlab.io.datastore。SimulationDatastore
目的)dst
without changing its current read position.预习
仅返回数据存储中数据的前十个示例(时间步)。使用此方法快速检查并验证数据是否如您预期出现。
输入参数
dst
-输入数据存储
matlab.io.datastore。SimulationDatastore
目的
输入数据存储,,,,specified as amatlab.io.datastore。SimulationDatastore
目的。To create aSimulationDatastore
对象,请参阅matlab.io.datastore。SimulationDatastore
。
例子
在模拟数据存储中检查和分析数据
此示例显示了如何通过与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);
放读取尺寸
至200
again.
dstore.ReadSize = 200;
Read from the datastore twice to advance the read position to the 401st sample.
阅读(dstore);阅读(dstore);
放读取尺寸
至5
again.
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
循环,使用hasdata
method, 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
版本历史记录
也可以看看
话题
matlab命令
您单击了与此MATLAB命令相对应的链接:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。金宝app
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
美洲
- América Latina(Español)
- 加拿大(英语)
- 单位ed States(英语)