preview
Class:matlab.io.datastore.sdidatastore
Package:matlab.io.datastore
Return preview of data in sdidatstore
Syntax
dataPreview= sdi_ds.preview
Description
returns the first 10 samples of signal data in thedataPreview
= sdi_ds.previewmatlab.io.datastore.sdidatastore
,sdi_ds
. Thepreview
method does not change the read position. Use thepreview
method to verify that the data in yourmatlab.io.datastore.sdidatastore
appears as you expect.
Output Arguments
dataPreview
— Preview of the data
timetable
First 10 samples of the signal referenced by thematlab.io.datastore.sdidatastore
in atimetable
.
Examples
Process Signal Data Using amatlab.io.datastore.sdidatastore
Amatlab.io.datastore.sdidatastore
references signal data in the Simulation Data Inspector repository. When the signal is too large to fit into memory, you can use thematlab.io.datastore.sdidatastore
to incrementally process the data manually or to create a tall timetable for the signal that handles the incremental processing for you. This example shows how to process data using amatlab.io.datastore.sdidatastore
.
创建一个matlab.io.datastore.sdidatastore
for a Signal
Simulate thesldemo_fuelsys
model, which is configured to log several signals, to create data in the Simulation Data Inspector repository.
sim卡('sldemo_fuelsys')
使用仿真数据检查器编程接口获取信号的信号ID。
runCount = Simulink.sdi.getRunCount; latestRunID = Simulink.sdi.getRunIDByIndex(runCount); latestRun = Simulink.sdi.getRun(latestRunID); speedSigID = latestRun.getSignalIDByIndex(4);
Use the signal ID to create amatlab.io.datastore.sdidatastore
为了speed
signal.
speedSDIds = matlab.io.datastore.sdidatastore(speedSigID);
Verify the Contents of the Datastore
Check theName
属性matlab.io.datastore.sdidatastore
to verify that it matches your expectations.
speedsdids.name
ans ='map'
You can also use thepreview
检查信号中的前十个样本是否看起来正确的方法。
speedSDIds.preview
ans=10×1 timetableTime Data ______________ _______ 0 sec 0.589 0.00056199 sec 0.58772 0.0033719 sec 0.58148 0.01 sec 0.56765 0.02 sec 0.54897 0.03 sec 0.53264 0.04 sec 0.51837 0.05 sec 0.50594 0.055328 sec 0.5 0.055328 sec 0.5
Process Signal Data with thematlab.io.datastore.sdidatastore
When your signal is too large to fit into memory, you can use thereadData
method to read chunks of data from the Simulation Data Inspector repository to incrementally process your data. Use thehasdata
method as the condition for a while loop to incrementally process the whole signal. For example, find the maximum signal value.
最新max = [];whilespeedsdids.hasdata speedchunk = speedsdids.reads.read;speedchunkdata = speedchunk.data;最新max = max([speedchunkdata;最终max]);endlatestMax
latestMax = 0.8897
On each read operation, theread
method updates the read position for the start of the next read operation. After reading some or all of thematlab.io.datastore.sdidatastore
, you can reset the read position to start again from the beginning of the signal.
speedSDIds.reset
Process Signal Data in Memory
When the signal referenced by yourmatlab.io.datastore.sdidatastore
fits into memory, you can use thereadall
将所有信号数据读取到存储器中进行处理的方法,而不是通过逐步读取和处理数据read
method. Thereadall
方法返回timetable
with all the signal data.
speedTimetable = speedSDIds.readall; speedMax = max(speedTimetable.Data)
speedMax = 0.8897
他的版本tory
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select:.
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- AméricaLatina(Español)
- Canada(English)
- United States(English)
Europe
- Belgium(English)
- 丹麦(English)
- Deutschland(Deutsch)
- España(Español)
- Finland(English)
- 法国(Français)
- 爱尔兰(English)
- Italia(Italiano)
- Luxembourg(English)
- Netherlands(English)
- 挪威(English)
- Österreich(Deutsch)
- Portugal(English)
- Sweden(English)
- Switzerland
- United Kingdom(English)