MATLAB Programming Fundamentals - MathWorks
One input is a matrix, and the other is a 3-D array. The dimensions are all either the same or one of them is 1. Compatible Ar ...
Empty Arrays The rules are the same for empty arrays or arrays that have a dimension size of zero. The size of the dimension tha ...
A: 3-by-2 B: 4-by-2 Two nonscalar row vectors with lengths that are not the same. A: 1-by-3 B: 1-by-4 Examples Subtract Vector ...
For example, add a row and column vector. The result is the same as bsxfun(@plus,a,b). a = [1 2 3 4] ans = 1 2 3 4 b = [5; 6; 7] ...
Array Comparison with Relational Operators In this section... “Array Comparison” on page 2-25 “Logic Statements” on page 2-28 Re ...
2 4 6 8 10 12 B = [5 5 5; 9 9 9] B = 5 5 5 9 9 9 A < B ans = 1 1 0 1 0 0 Similarly, you can compare one of the arrays to a sc ...
0 1 1 0 0 1 Empty Arrays The relational operators work with arrays for which any dimension has size zero, as long as both arrays ...
Logic Statements Use relational operators in conjunction with the logical operators A & B (AND), A | B (OR), xor(A,B) (XOR), ...
Operator Precedence You can build expressions that use any combination of arithmetic, relational, and logical operators. Precede ...
The same precedence rule holds true for the && and || operators. Overriding Default Precedence The default precedence ca ...
Average Similar Data Points Using a Tolerance This example shows how to use uniquetol to find the average z-coordinate of 3-D po ...
Find points that have similar x and y coordinates using uniquetol with these options: Specify ByRows as true, since the rows of ...
See Also uniquetol More About “Group Scattered Data Using a Tolerance” on page 2-34 See Also ...
Group Scattered Data Using a Tolerance This example shows how to group scattered data points based on their proximity to points ...
Use ismembertol to locate the data points in x that are within tolerance of the grid points in gridPoints. Use these options wit ...
for k = 1:length(LocB) plot(x(LocB{k},1), x(LocB{k},2), '.') end plot(gridPoints(:,1), gridPoints(:,2), 'xr', 'Markersize', 6) S ...
Conditional Statements Conditional statements enable you to select at run time which block of code to execute. The simplest cond ...
disp('Weekend!') end For both if and switch, MATLAB executes the code corresponding to the first true condition, and then exits ...
Loop Control Statements With loop control statements, you can repeatedly execute a block of code. There are two types of loops: ...
while ~feof(fid) line = fgetl(fid); if isempty(line) break elseif ~strncmp(line,'%',1) continue end count = count + 1; end fprin ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf