MATLAB Programming Fundamentals - MathWorks
x = [4/3 1.2345e-6] x = 1.3333 0.0000 Set the format to 5-digit floating point: format short e x x = 1.3333e+00 1.2345e-06 Set t ...
...
The Logical Class “Find Array Elements That Meet a Condition” on page 5-2 “Determine if Arrays Are Logical” on page 5-7 “Reduce ...
Find Array Elements That Meet a Condition This example shows how to filter the elements of an array by applying conditions to th ...
< 9. For example, A(1,1) is 13 , so B(1,1) is logical 0 (false). However, A(1,2) is 2 , so B(1,2) is logical 1 (true). Althou ...
The result is a column vector of linear indices. Each index describes the location of an element in A that is less than 9, so in ...
Finally, find the elements in A that are less than 9 and even numbered and not equal to 2. A(A<9 & ~mod(A,2) & A~=2) ...
10 NaN 10 NaN NaN NaN NaN 10 10 10 10 10 NaN 10 10 10 10 10 10 10 Lastly, replace all of the NaN values in A with zeros and appl ...
Determine if Arrays Are Logical To determine whether an array is logical, you can test the entire array or each element individu ...
Test an Entire Array Use the islogical function to test whether A is logical. islogical(A) ans = 1 The result is logical 1 (true ...
The result is a matrix of logical values of the same size as A. arrayfun(@islogical,A) always returns a matrix of all logical 1 ...
See Also arrayfun | cellfun | class | isa | islogical | whos 5 The Logical Class ...
Reduce Logical Arrays to Single Value This example shows how to use the any and all functions to reduce an entire array to a sin ...
The resulting matrices have values of logical 1 (true) where an element is even, and logical 0 (false) where an element is odd. ...
See Also Logical Operators: Short Circuit | all | and | any | or | xor See Also ...
Truth Table for Logical Operations The following reference table shows the results of applying the binary logical operators to a ...
Characters and Strings “Represent Text with Character and String Arrays” on page 6-2 “Create Character Arrays” on page 6-6 “Cre ...
Represent Text with Character and String Arrays There are two ways to represent text in MATLAB®. You can store text in character ...
Represent Text with String Arrays You also can store text in string arrays. Each element of a string array stores a 1-by-n chara ...
str is a 2-by-3 string array. You can find the lengths of the strings with the strlength function. whos str Name Size Bytes Clas ...
«
5
6
7
8
9
10
11
12
13
14
»
Free download pdf