MATLAB中datastore函数用法

目录

语法

说明

示例

为文本数据创建数据存储

为图像数据创建数据存储


        datastore函数的功能是为大型数据集合创建数据存储。

语法

ds = datastore(location)
ds = datastore(location,Name,Value)

说明

        ds = datastore(location) 根据 location 指定的数据集合创建一个数据存储。数据存储是一个存储库,用于收集由于体积太大而无法载入内存的数据。创建 ds 后,可以读取并处理数据。

        ds = datastore(location,Name,Value) 使用一个或多个名称-值对组参数为 ds 指定其他参数。例如,可以通过指定 'Type','image' 为图像文件创建数据存储。

示例

为文本数据创建数据存储

        创建一个与示例文件 airlinesmall.csv 关联的数据存储。此文件包含从 1987 至 2008 年的航空公司数据。

        要控制如何在数值列中导入缺失的数据,请使用 "TreatAsMissing" 和 "MissingValue" 名称-值参数。通过将 "TreatAsMissing" 的值指定为 "NA" 并将 "MissingValue" 的值指定为 0,在导入的数据中用 0 替换每个 "NA" 实例。

ds = datastore("airlinesmall.csv","TreatAsMissing","NA",...
               "MissingValue",0)
ds = 
  TabularTextDatastore with properties:

                      Files: {
                             'B:\matlab\toolbox\matlab\demos\airlinesmall.csv'
                             }
                    Folders: {
                             'B:\matlab\toolbox\matlab\demos'
                             }
               FileEncoding: 'UTF-8'
   AlternateFileSystemRoots: {}
         VariableNamingRule: 'modify'
          ReadVariableNames: true
              VariableNames: {'Year', 'Month', 'DayofMonth' ... and 26 more}
             DatetimeLocale: en_US

  Text Format Properties:
             NumHeaderLines: 0
                  Delimiter: ','
               RowDelimiter: '\r\n'
             TreatAsMissing: 'NA'
               MissingValue: 0

  Advanced Text Format Properties:
            TextscanFormats: {'%f', '%f', '%f' ... and 26 more}
                   TextType: 'char'
         ExponentCharacters: 'eEdD'
               CommentStyle: ''
                 Whitespace: ' \b\t'
    MultipleDelimitersAsOne: false

  Properties that control the table returned by preview, read, readall:
      SelectedVariableNames: {'Year', 'Month', 'DayofMonth' ... and 26 more}
            SelectedFormats: {'%f', '%f', '%f' ... and 26 more}
                   ReadSize: 20000 rows
                 OutputType: 'table'
                   RowTimes: []

  Write-specific Properties:
     SupportedOutputFormats: ["txt"    "csv"    "xlsx"    "xls"    "parquet"    "parq"]
        DefaultOutputFormat: "txt"
datastore 创建一个 TabularTextDatastore。

为图像数据创建数据存储

        创建一个包含 MATLAB® 路径及其子文件夹中的所有 .tif 文件的数据存储。

ds = datastore(fullfile(matlabroot,"toolbox","matlab"),...
"IncludeSubfolders",true,"FileExtensions",".tif","Type","image")
ds = ImageDatastore with properties:
                       Files: {
                              'H:\matlab\toolbox\matlab\demos\example.tif';
                              'H:\matlab\toolbox\matlab\imagesci\corn.tif'
                              }
                     Folders: {
                              'H:\matlab\toolbox\matlab'
                              }
    AlternateFileSystemRoots: {}
                    ReadSize: 1
                      Labels: {}
      SupportedOutputFormats: ["png"    "jpg"    "jpeg"    "tif"    "tiff"]
         DefaultOutputFormat: "png"
                     ReadFcn: @readDatastoreImage

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值