به دست آوردن مشخصات یک جدول (Table)، با Properties ، در متلب (MATLAB)
در متلب (MATLAB)، با استفاده از Properties می توانیم مشخصات یک جدول (Table) را به دست آوریم. یعنی مثلا اگر جدولی با نام My_Table داشته باشیم، آنگاه عبارت زیر، مشخصات این جدول را برمی گرداند :
xxxxxxxxxx
My_Table.Properties
به مثال زیر توجه کنید :
xxxxxxxxxx
clear all
close all
clc
column_1 = [1; 2; 3];
column_2 = [4; 5; 6];
column_3 = [7; 8; 9];
My_Table = table(column_1,column_2,column_3, ...
'RowNames',{'Row_1' 'Row_2' 'Row_3'})
Table_Info = My_Table.Properties
3 خط اول کدها، برای عدم تداخل برنامه فعلی با برنامه های قبلی اجرا شده در متلب (MATLAB) می باشد.
نتیجه :
xxxxxxxxxx
My_Table =
3×3 table
column_1 column_2 column_3
________ ________ ________
Row_1 1 4 7
Row_2 2 5 8
Row_3 3 6 9
Table_Info =
struct with fields:
Description: ''
UserData: []
DimensionNames: {'Row' 'Variables'}
VariableNames: {'column_1' 'column_2' 'column_3'}
VariableDescriptions: {}
VariableUnits: {}
VariableContinuity: []
RowNames: {3×1 cell}
هر یک از مشخصه های ذخیره شده در Properties را به صورت تک تک نیز می توانیم بررسی کنیم. به عنوان مثال، در مشخصه Properties.VariableNames نام ستون های (Column) جدول (Table) ذخیره شده است و برای جدولی با نام My_Table می توانیم با عبارت زیر آن را به دست آوریم :
xxxxxxxxxx
My_Table.Properties.VariableNames
و در مشخصه Properties.RowNames نام ردیف های (Row) جدول (Table) ذخیره شده است و برای جدولی با نام My_Table می توانیم با عبارت زیر آن را به دست آوریم :
xxxxxxxxxx
My_Table.Properties.RowNames
به مثال زیر توجه کنید :
xxxxxxxxxx
clear all
close all
clc
column_1 = [1; 2; 3];
column_2 = [4; 5; 6];
column_3 = [7; 8; 9];
My_Table = table(column_1,column_2,column_3, ...
'RowNames',{'Row_1' 'Row_2' 'Row_3'})
Table_Info = My_Table.Properties
Columns_Name = My_Table.Properties.VariableNames
Rows_Name = My_Table.Properties.RowNames
نتیجه :
xxxxxxxxxx
My_Table =
3×3 table
column_1 column_2 column_3
________ ________ ________
Row_1 1 4 7
Row_2 2 5 8
Row_3 3 6 9
Table_Info =
struct with fields:
Description: ''
UserData: []
DimensionNames: {'Row' 'Variables'}
VariableNames: {'column_1' 'column_2' 'column_3'}
VariableDescriptions: {}
VariableUnits: {}
VariableContinuity: []
RowNames: {3×1 cell}
Columns_Name =
1×3 cell array
{'column_1'} {'column_2'} {'column_3'}
Rows_Name =
3×1 cell array
{'Row_1'}
{'Row_2'}
{'Row_3'}