-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ad6c3e1
commit 984a123
Showing
17 changed files
with
334 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Direct computation with Table | ||
|
||
## Description | ||
|
||
<p>You can perform calculations directly on tableswithout needing to index into them.</p> | ||
<p>To perform such operations using the same syntax as you would for arrays, your tables must meet several criteria:</p> | ||
<p>All variables within the table must have data types that support the intended calculations (e.g., numeric or logical types).</p> | ||
<p>When performing an operation where only one operand is a table, the other operand must be either a numeric or logical array.</p> | ||
<p>For operations involving two tables, they must have compatible sizes (i.e., the same number of rows and columns or the operation must make sense for the structures involved).</p> | ||
<p/> | ||
<p>Below is an example that demonstrates how to perform calculations without explicitly indexing into the table.</p> | ||
|
||
## Example | ||
|
||
Adding a New Column | ||
|
||
```matlab | ||
% Create a sample table with sensor data | ||
T = table([1.5; -2.3; 4.7], [0.5; 1.1; -0.7], [-1; 2; 3], ... | ||
'VariableNames', {'Voltage', 'Current', 'Resistance'}); | ||
% Apply functions directly to the table columns | ||
abs(T) | ||
acos(T) | ||
acosh(T) | ||
T > 1 | ||
T + 2 | ||
T .* T | ||
abs(sin(T)) + 1 | ||
``` | ||
|
||
## See also | ||
|
||
[abs](../elementary_functions/abs.md), [acos](../trigonometric_functions/acos.md), [acosh](../trigonometric_functions/acosh.md), [acot](acot.html), [acotd](acotd.html), [acoth](acoth.html), [acsc](acsc.html), [acscd](acscd.html), [acsch](acsch.html), [asec](asec.html), [asecd](asecd.html), [asech](asech.html), [asin](../trigonometric_functions/asin.md), [asind](../trigonometric_functions/asind.md), [asinh](../trigonometric_functions/asinh.md), [atan](../trigonometric_functions/atan.md), [atand](../trigonometric_functions/atand.md), [atanh](../trigonometric_functions/atanh.md), [ceil](../elementary_functions/ceil.md), [cosd](cosd.html), [cosh](cosh.html), [cospi](../trigonometric_functions/cospi.md), [cot](cot.html), [cotd](cotd.html), [coth](coth.html), [csc](csc.html), [cscd](cscd.html), [csch](csch.html), [exp](../elementary_functions/exp.md), [fix](../elementary_functions/fix.md), [floor](../elementary_functions/floor.md), [log](../elementary_functions/log.md), [log10](../elementary_functions/log10.md), [log1p](../elementary_functions/log1p.md), [log2](../elementary_functions/log2.md), [nextpow2](../elementary_functions/nextpow2.md), [round](../elementary_functions/round.md), [sec](sec.html), [secd](secd.html), [sech](sech.html), [sin](sin.html), [sind](sind.html), [sinh](sinh.html), [sinpi](../trigonometric_functions/sinpi.md), [sqrt](../elementary_functions/sqrt.md), [tan](../trigonometric_functions/tan.md), [tand](../trigonometric_functions/tand.md), [tanh](../trigonometric_functions/tanh.md), [var](../statistics/var.md), [acosd](../trigonometric_functions/acosd.md), [not](../operators/not.md), [plus](plus.html), [minus](../elementary_functions/minus.md), [times](times.html), [eq](eq.html), [ge](ge.html), [gt](gt.html), [le](le.html), [ne](ne.html), [lt](lt.html), [mrdivide](../operators/mrdivide.md), [rem](../elementary_functions/rem.md), [power](../operators/power.md), [pow2](../elementary_functions/pow2.md), [or](../operators/or.md), [mod](../elementary_functions/rem.md), [ldivide](../operators/ldivide.md). | ||
|
||
## History | ||
|
||
| Version | Description | | ||
| ------- | --------------- | | ||
| 1.9.0 | initial version | | ||
|
||
## Author | ||
|
||
Allan CORNET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
- [table](README.md) | ||
- [Accessing and Manipulating Tables in Nelson](accessing_manipulating_table.md) | ||
- [Accessing and Manipulating Tables in Nelson](1_accessing_manipulating_table.md) | ||
- [Direct computation with Table](2_direct_compution_with_table.md) | ||
- [array2table](array2table.md) | ||
- [cell2table](cell2table.md) | ||
- [head](head.md) | ||
- [height](height.md) | ||
- [istable](istable.md) | ||
- [removevars](removevars.md) | ||
- [renamevars](renamevars.md) | ||
- [struct2table](struct2table.md) | ||
- [table](table.md) | ||
- [table2array](table2array.md) | ||
- [table2cell](table2cell.md) | ||
- [table2struct](table2struct.md) | ||
- [tail](tail.md) | ||
- [width](width.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# head | ||
|
||
Get top rows of table or array. | ||
|
||
## Syntax | ||
|
||
- head(A) | ||
- head(A, k) | ||
- B = head(...) | ||
|
||
## Input argument | ||
|
||
- A - Input array (table or other). | ||
|
||
## Output argument | ||
|
||
- k - a integer value: Number of rows to extract (k = 8 by default). | ||
|
||
## Description | ||
|
||
<p><b>head(A)</b> displays the first eight rows of an array, or table <b>A</b> in the Command Window without assigning it to a variable.</p> | ||
<p><b>head(A, k)</b> displays the first k rows of A.</p> | ||
<p><b>B = head(...)</b> returns the specified rows of <b>A</b> for any of the previous syntaxes, with <b>B</b> having the same data type as <b>A</b>.</p> | ||
|
||
## Examples | ||
|
||
```matlab | ||
LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'}; | ||
Age = [38;43;38;40;49]; | ||
Smoker = logical([1;0;1;0;1]); | ||
Height = [71;69;64;67;64]; | ||
Weight = [176;163;131;133;119]; | ||
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80]; | ||
T = table(LastName, Age, Smoker, Height, Weight, BloodPressure) | ||
head(T, 2) | ||
``` | ||
|
||
```matlab | ||
A = repmat((1:50)',1, 3); | ||
head(A) | ||
``` | ||
|
||
## See also | ||
|
||
[tail](tail.md), [table](table.md). | ||
|
||
## History | ||
|
||
| Version | Description | | ||
| ------- | --------------- | | ||
| 1.9.0 | initial version | | ||
|
||
## Author | ||
|
||
Allan CORNET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# removevars | ||
|
||
Delete variables from table. | ||
|
||
## Syntax | ||
|
||
- TB = removevars(TA, varsNames) | ||
|
||
## Input argument | ||
|
||
- TA - Input table. | ||
- varsNames - Variable names in input table to remove: character vector, string array or cell array of character vectors. | ||
|
||
## Output argument | ||
|
||
- TB - Table object modified. | ||
|
||
## Description | ||
|
||
<p><b>TB = removevars(TA, varsNames)</b> removes the variables specified by <b>varsNames</b> from the table <b>TA</b> and stores the remaining variables in <b>T2</b>.</p> | ||
<p>You can specify the variables by name, position, or using logical indices.</p> | ||
<p>You can also remove variables from a table using <b>T(:, varsNames) = []</b>.</p> | ||
|
||
## Example | ||
|
||
```matlab | ||
C = {'John', 28, true; 'Alice', 35, false; 'Bob', 42, true}; | ||
% Convert the cell array to a table | ||
T1 = cell2table(C) | ||
T2 = removevars(T1, 'C2') | ||
``` | ||
|
||
## See also | ||
|
||
[table](table.md), [renamevars](renamevars.md). | ||
|
||
## History | ||
|
||
| Version | Description | | ||
| ------- | --------------- | | ||
| 1.9.0 | initial version | | ||
|
||
## Author | ||
|
||
Allan CORNET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# renamevars | ||
|
||
Rename variables in table. | ||
|
||
## Syntax | ||
|
||
- TB = renamevars(TA, varsNames, newNames) | ||
|
||
## Input argument | ||
|
||
- TA - Input table. | ||
- varsNames - Variable names in input table: character vector, string array or cell array of character vectors. | ||
- newNames - New names for variables: character vector, string array or cell array of character vectors. | ||
|
||
## Output argument | ||
|
||
- TB - Table object with variable names modified. | ||
|
||
## Description | ||
|
||
<p><b>TB = renamevars(TA, varsNames, newNames)</b> renames the variables in the table <b>TA</b> as specified by <b>varsNames</b> and assigns them the new names provided in <b>newNames</b>.</p> | ||
<p>You can also rename all the variables in a table by assigning new names to its <b>VariableNames</b> property using <b>T.Properties.VariableNames = newNames</b>.</p> | ||
<p>In this case, <b>newNames</b> must be a string array or a cell array of character vectors.</p> | ||
|
||
## Example | ||
|
||
```matlab | ||
C = {'John', 28, true; 'Alice', 35, false; 'Bob', 42, true}; | ||
% Convert the cell array to a table | ||
T1 = cell2table(C); | ||
T2 = renamevars(T1, {'C1', 'C2'}, {'Name', 'Age'}) | ||
T3 = cell2table(C); | ||
T3.Properties.VariableNames = {'Name', 'Age', 'Married'}; | ||
T3 | ||
``` | ||
|
||
## See also | ||
|
||
[table](table.md), [removevars](removevars.md). | ||
|
||
## History | ||
|
||
| Version | Description | | ||
| ------- | --------------- | | ||
| 1.9.0 | initial version | | ||
|
||
## Author | ||
|
||
Allan CORNET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# tail | ||
|
||
Get bottom rows of table or array. | ||
|
||
## Syntax | ||
|
||
- tail(A) | ||
- tail(A, k) | ||
- B = tail(...) | ||
|
||
## Input argument | ||
|
||
- A - Input array (table or other). | ||
|
||
## Output argument | ||
|
||
- k - a integer value: Number of rows to extract (k = 8 by default). | ||
|
||
## Description | ||
|
||
<p><b>tail(A)</b> displays the last eight rows of an array, or table <b>A</b> in the Command Window without assigning it to a variable.</p> | ||
<p><b>tail(A, k)</b> displays the last k rows of A.</p> | ||
<p><b>B = tail(...)</b> returns the specified rows of <b>A</b> for any of the previous syntaxes, with <b>B</b> having the same data type as <b>A</b>.</p> | ||
|
||
## Examples | ||
|
||
```matlab | ||
LastName = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'}; | ||
Age = [38;43;38;40;49]; | ||
Smoker = logical([1;0;1;0;1]); | ||
Height = [71;69;64;67;64]; | ||
Weight = [176;163;131;133;119]; | ||
BloodPressure = [124 93; 109 77; 125 83; 117 75; 122 80]; | ||
T = table(LastName, Age, Smoker, Height, Weight, BloodPressure) | ||
tail(T, 2) | ||
``` | ||
|
||
```matlab | ||
A = repmat((1:50)',1, 3); | ||
tail(A) | ||
``` | ||
|
||
## See also | ||
|
||
[head](head.md), [table](table.md). | ||
|
||
## History | ||
|
||
| Version | Description | | ||
| ------- | --------------- | | ||
| 1.9.0 | initial version | | ||
|
||
## Author | ||
|
||
Allan CORNET |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.