Hướng dẫn spreadsheet import options matlab - matlab tùy chọn nhập bảng tính
bảng tínhImportOptionsNhập tùy chọn đối tượng cho bảng tính Show
Sự mô tảĐối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 cho phép bạn chỉ định cách nhập dữ liệu bảng MATLAB® từ các tệp bảng tính. Đối tượng chứa các thuộc tính kiểm soát quá trình nhập dữ liệu, bao gồm việc xử lý các lỗi và dữ liệu bị thiếu. Sự sáng tạoBạn có thể tạo đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 bằng cách sử dụng hàm opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)3 hoặc hàm opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)4 (được mô tả ở đây):
Cú phápSự mô tảĐối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 cho phép bạn chỉ định cách nhập dữ liệu bảng MATLAB® từ các tệp bảng tính. Đối tượng chứa các thuộc tính kiểm soát quá trình nhập dữ liệu, bao gồm việc xử lý các lỗi và dữ liệu bị thiếu. Sự sáng tạo creates a opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 object with one variable. Đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 cho phép bạn chỉ định cách nhập dữ liệu bảng MATLAB® từ các tệp bảng tính. Đối tượng chứa các thuộc tính kiểm soát quá trình nhập dữ liệu, bao gồm việc xử lý các lỗi và dữ liệu bị thiếu. Sự sáng tạo creates the object with the number of variables specified in ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
1.Đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 cho phép bạn chỉ định cách nhập dữ liệu bảng MATLAB® từ các tệp bảng tính. Đối tượng chứa các thuộc tính kiểm soát quá trình nhập dữ liệu, bao gồm việc xử lý các lỗi và dữ liệu bị thiếu. Sự sáng tạo specifies additional properties for opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 object using one or more name-value pair arguments. Bạn có thể tạo đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 bằng cách sử dụng hàm opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)3 hoặc hàm opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)4 (được mô tả ở đây):Sử dụng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)3 để phát hiện và điền vào các thuộc tính nhập dựa trên nội dung của bảng tính được chỉ định trong opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)6. Sử dụng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)4 để xác định các thuộc tính nhập dựa trên các yêu cầu nhập của bạn.Number of variables positive scalar integerCú pháp thí dụSử dụng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)3 để phát hiện và điền vào các thuộc tính nhập dựa trên nội dung của bảng tính được chỉ định trong opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)6. Sử dụng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)4 để xác định các thuộc tính nhập dựa trên các yêu cầu nhập của bạn.Cú pháp thí dụ opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)8 Tạo một đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 với một biến.
oneVar = readtable('patients.xls',opts); whos oneVar1 returns the current (detected) variable names.
oneVar = readtable('patients.xls',opts); whos oneVar2 changes the name of the third variable to oneVar = readtable('patients.xls',opts); whos oneVar3. Đối số đầu vào oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | oneVar = readtable('patients.xls',opts); whos oneVar6 mở rộng tất cả — Flag to preserve variable names oneVar = readtable('patients.xls',opts); whos oneVar8 (default) | oneVar = readtable('patients.xls',opts); whos oneVar9ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
1 - Số lượng vô hướng variablespositive
Thuộc tính biến Tên biến, được chỉ định là một mảng ô của các vectơ ký tự hoặc mảng chuỗi. Thuộc tính oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 Nếu dữ liệu chứa các biến ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
6, nhưng không có tên biến nào được chỉ định, thì thuộc tính ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
5 chứa ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
8.Để hỗ trợ các định danh MATLAB không hợp lệ dưới dạng tên biến, chẳng hạn như tên biến có chứa khoảng trắng và ký tự không phải ASCII, đặt giá trị của ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
9 thành oneVar = readtable('patients.xls',opts); whos oneVar0. Ví dụ: numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';6 returns the current variable data types. Ví dụ: numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';7 changes the data type of the variable oneVar = readtable('patients.xls',opts); whos oneVar3 to numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9. Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | oneVar = readtable('patients.xls',opts); whos oneVar6
ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
9 - cờ để bảo tồn tên biến ____38 (mặc định) | oneVar = readtable('patients.xls',opts); whos oneVar9 Cờ để bảo tồn tên biến, được chỉ định là oneVar = readtable('patients.xls',opts); whos oneVar8 hoặc oneVar = readtable('patients.xls',opts); whos oneVar9. opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)8 Tạo một đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1 với một biến.
opts = spreadsheetImportOptions('NumVariables',numVars,... 'VariableNames',varNames,... 'VariableTypes',varTypes,... 'DataRange', dataStartLoc);9 selects only two variables, oneVar = readtable('patients.xls',opts); whos oneVar3 and preview('patients.xls',opts) 1, for the import operation.
preview('patients.xls',opts) 2 selects only two variables, the first variable and the fifth variable, for the import operation.Đối số đầu vào preview('patients.xls',opts) 3 returns a table containing only the variables specified in the opts = spreadsheetImportOptions('NumVariables',numVars,... 'VariableNames',varNames,... 'VariableTypes',varTypes,... 'DataRange', dataStartLoc);0 property of the preview('patients.xls',opts) 5 object.mở rộng tất cả preview('patients.xls',opts) 6 | preview('patients.xls',opts) 7 | preview('patients.xls',opts) 8 | oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | oneVar = readtable('patients.xls',opts); whos oneVar6 ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
1 - Số lượng vô hướng variablespositiveTùy chọn biến hỗ trợ các loại dữ liệu này: Số, văn bản, ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
3, ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
4 hoặc ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
5.Để truy vấn các tùy chọn hiện tại (hoặc được phát hiện) cho một biến, hãy sử dụng hàm ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
6.Để đặt và tùy chỉnh tùy chọn cho một biến, hãy sử dụng hàm ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
7.Ví dụ: ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
8 returns a collection of ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
9 objects, one corresponding to each variable in the data. Ví dụ: T = readtable('patients.xls',opts); whos T0 returns the ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
9 object for the oneVar = readtable('patients.xls',opts); whos oneVar3 variable. Ví dụ: T = readtable('patients.xls',opts); whos T3 sets the T = readtable('patients.xls',opts); whos T4 property for the variable oneVar = readtable('patients.xls',opts); whos oneVar3 to T = readtable('patients.xls',opts); whos T6. Thuộc tính vị tríBảng để đọc từ, được chỉ định là một mảng ký tự trống, vectơ ký tự hoặc vô hướng chuỗi chứa tên trang tính hoặc số nguyên vô hướng dương biểu thị chỉ mục trang tính. Dựa trên giá trị được chỉ định cho thuộc tính T = readtable('patients.xls',opts); whos T7, hàm nhập hoạt động như được mô tả trong bảng.
Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)03 - Vị trí của vector datacharacter | Chuỗi vô hướng | Số nguyên vô hướng tích cực | Mảng số nguyên vô hướng tích cực | Mảng ô của vectơ ký tự | Mảng chuỗi — Location of data character vector | string scalar | positive scalar integer | array of positive scalar integers | cell array of character vector | string arrayVị trí của dữ liệu được nhập, được chỉ định là vectơ ký tự, vô hướng chuỗi, mảng ô của các vectơ ký tự, mảng chuỗi, số nguyên vô hướng dương hoặc ____ ____ 26-BY -____ 105 Mảng số nguyên vô hướng dương. Chỉ định opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)03 bằng một trong các hình thức này.
Phạm vi nhiều hàng oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | oneVar = readtable('patients.xls',opts); whos oneVar6 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 Chỉ định nhiều phạm vi hàng để đọc với một mảng ____ ____ 26-by -____ 105 chứa ans=8×1 table LastName ________ Smith Johnson Williams Jones Brown Davis Miller Wilson 6 Phạm vi hàng khác nhau. — Location of row names character vector | string scalar | positive scalar integer | T = readtable('patients.xls',opts); whos T8 empty character arrayMột mảng hợp lệ gồm nhiều phạm vi hàng phải:
Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 - Vị trí của vectơ tên biến đổi biến đổi | Chuỗi vô hướng | Số nguyên vô hướng tích cực | T = readtable('patients.xls',opts); whos T8 Mảng ký tự trống — Location of variable names character vector | string scalar | positive scalar integer | T = readtable('patients.xls',opts); whos T8 empty character arrayVị trí của các tên biến, được chỉ định là vectơ ký tự, vô hướng chuỗi, số nguyên vô hướng dương hoặc mảng ký tự trống. Chỉ định opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 là một trong các giá trị trong bảng này.
Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 - Vị trí của vectơ tên biến đổi biến đổi | Chuỗi vô hướng | Số nguyên vô hướng tích cực | T = readtable('patients.xls',opts); whos T8 Mảng ký tự trống — Location of variable descriptions character vector | string scalar | T = readtable('patients.xls',opts); whos T8 empty character arrayVị trí của các tên biến, được chỉ định là vectơ ký tự, vô hướng chuỗi, số nguyên vô hướng dương hoặc mảng ký tự trống. Chỉ định opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 là một trong các giá trị trong bảng này.
Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 - Vị trí của vectơ tên biến đổi biến đổi | Chuỗi vô hướng | Số nguyên vô hướng tích cực | T = readtable('patients.xls',opts); whos T8 Mảng ký tự trống — Location of variable units character vector | string scalar | positive scalar integer | T = readtable('patients.xls',opts); whos T8 empty character arrayVị trí của các tên biến, được chỉ định là vectơ ký tự, vô hướng chuỗi, số nguyên vô hướng dương hoặc mảng ký tự trống. Chỉ định opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)63 là một trong các giá trị trong bảng này.
Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 | opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)01 | numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2';9 Quy tắc thay thếQuy trình để quản lý dữ liệu bị thiếu, được chỉ định là một trong các giá trị trong bảng này.
Ví dụ: ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
43Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 Quy trình để xử lý các lỗi nhập, được chỉ định là một trong các giá trị trong bảng này.
Ví dụ: ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
55Kiểu dữ liệu: oneVar = readtable('patients.xls',opts); whos oneVar4 | oneVar = readtable('patients.xls',opts); whos oneVar5 Quy trình để xử lý các lỗi nhập, được chỉ định là một trong các giá trị trong bảng này.Nhập quy tắc lỗiThay thế dữ liệu nơi xảy ra lỗi với nội dung của thuộc tính T = readtable('patients.xls',opts); whos T4. Ngừng nhập và hiển thị thông báo lỗi hiển thị bản ghi và trường gây ra lỗi.Bỏ qua các hàng nơi xảy ra lỗi. Bỏ qua các biến nơi xảy ra lỗi. opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts) ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
Ví dụ: ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
55oneVar = readtable('patients.xls',opts); whos oneVar Name Size Bytes Class Attributes oneVar 100x1 12709 table Chức năng đối tượngVí dụ sụp đổ tất cả numVars = 7; varNames = {'LastName','Gender','Age','Location','Height','Weight','Smoker'} ; varTypes = {'char','categorical','int32','char','double','double','logical'} ; dataStartLoc = 'A2'; Xác định các tùy chọn nhập cho biến trong tệp bảng tính opts = spreadsheetImportOptions('NumVariables',numVars,... 'VariableNames',varNames,... 'VariableTypes',varTypes,... 'DataRange', dataStartLoc); Tạo một đối tượng Tùy chọn nhập để đọc một biến từ tệp ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
58.preview('patients.xls',opts) ans=8×7 table
LastName Gender Age Location Height Weight Smoker
____________ ______ ___ _____________________________ ______ ______ ______
{'Smith' } Male 38 {'County General Hospital' } 71 176 true
{'Johnson' } Male 43 {'VA Hospital' } 69 163 false
{'Williams'} Female 38 {'St. Mary's Medical Center'} 64 131 false
{'Jones' } Female 40 {'VA Hospital' } 67 133 false
{'Brown' } Female 49 {'County General Hospital' } 64 119 false
{'Davis' } Female 46 {'St. Mary's Medical Center'} 68 142 false
{'Miller' } Female 33 {'VA Hospital' } 64 142 true
{'Wilson' } Male 40 {'VA Hospital' } 68 180 false
Khởi tạo đối tượng opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)1, chỉ định tên biến, loại biến và ô bắt đầu dữ liệu. Sau đó, sử dụng chức năng ans=8×1 table
LastName
________
Smith
Johnson
Williams
Jones
Brown
Davis
Miller
Wilson
60 với đối tượng Tùy chọn nhập để xem trước dữ liệu.T = readtable('patients.xls',opts); whos T opts = spreadsheetImportOptions; opts.VariableNames = 'LastName'; opts.VariableTypes = 'categorical'; opts.DataRange = 'A2'; preview('patients.xls',opts)0 Nhập biến từ tệp.
|