Please see my comment. If your input is a vector (i.e. one-dimensional), then [maxValue indexToMaxValue] = max(inputVector); Answer from the cyclist on mathworks.com
Discussions

Use a vector as an index
I have a matrix of variable dimension and would like to access it with an index stored in a variable, something like this: matrix = [1, 2; 3, 4; 5, 6] idx = [3, 1] elem = matrix(idx) % s... More on mathworks.com
🌐 mathworks.com
1
0
November 5, 2014
How can I index a vector based on the vector's values?
How can I index a vector based on the... Learn more about indexing More on mathworks.com
🌐 mathworks.com
2
0
March 13, 2020
matlab - Use a vector as an index to a matrix - Stack Overflow
I'm writing a MATLAB function to read out data into an n-dimensional array (variable dimension size). I need to be able to access a specific point in the Matrix (to write to it or read it, for exam... More on stackoverflow.com
🌐 stackoverflow.com
Why is indexing vectors/matrices in MATLAB very inefficient?
Why is indexing vectors/matrices in MATLAB very... Learn more about performance, indexing, obscure behavior More on mathworks.com
🌐 mathworks.com
5
15
November 22, 2012
🌐
MyScale
myscale.com › blog › efficient-data-manipulation-matlab-vector-indexing-step-by-step-guide
Master MATLAB Vector Indexing for Efficient Data Manipulation
April 3, 2024 - Let's delve into how vector indexing ... in MATLAB, accessing specific elements is vital. MATLAB allows you to pinpoint elements within a matrix using their respective indices....
🌐
Vt
matlab.enge.vt.edu › indexing.html
Vector Indexing
In MATLAB, the first element is given an index of 1. This differs from other programming languages, such as C, Java, and Python, which index from 0. ... Parentheses are used to identify a specific element within an array. In the following screenshot, Vector(2) is accessing the value of the ...
Find elsewhere
🌐
MathWorks
mathworks.com › matlab › language fundamentals › matrices and arrays
Array Indexing - MATLAB & Simulink
For example, check which elements of a string vector are missing using the ismissing function. str = ["A" "B" missing "D" "E" missing]; ind = ismissing(str) ... Suppose you want to find the values of the elements that are not missing. Use the ~ operator with the index vector ind to do this.
🌐
MathWorks
mathworks.com › matlab › language fundamentals › matrices and arrays
Detailed Rules for Array Indexing - MATLAB & Simulink
This topic discusses how MATLAB handles indexing into arrays using subscript vectors. MATLAB follows specific indexing rules when you specify indices as subscript vectors. While MATLAB supports subscript matrices and multidimensional arrays as indices, you can convert these indices to subscript ...
🌐
MathWorks
mathworks.com › matlab › language fundamentals › matrices and arrays
Indexed Assignment - MATLAB & Simulink
Create a 1-by-4 vector of zeros. ... Replace the second, third, and fourth elements of v with 10, 15, and 20, respectively. Specify the indices of the elements you want to replace on the left side of the assignment operator and the new values on the right side. ... In most cases, the number of elements on the right side should match the number of indexed elements on the left. However, MATLAB supports scalar expansion, where it expands a single scalar value on the right side to replace multiple elements on the left.
🌐
MathWorks
mathworks.com › company › technical-articles › matrix-indexing-in-matlab.html
Matrix Indexing in MATLAB - MATLAB & Simulink
Tip: MATLAB is column major–linear indexing starts by going down the columns consecutively. ... The expression A(14) simply extracts the 14th element of the implicit column vector.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 54522-why-is-indexing-vectors-matrices-in-matlab-very-inefficient
Why is indexing vectors/matrices in MATLAB very inefficient? - MATLAB Answers - MATLAB Central
November 22, 2012 - Method 1 is suitable if you want to set all vector elements to some value. But if you want to access elements every step entries, you need to substitute the : with e.g., 1:step:end. Below is a direct speed comparison with method 1: ... Elapsed time is 0.496476 seconds. While you would not expect it to perform any different, method 2 is clearly big trouble: factor 5 slowdown for no reason. My suspicion is that in this case MATLAB explicitly allocates the index vector (1:end).
🌐
MathWorks
mathworks.com › matlab › mathematics › sparse matrices
find - Find indices and values of nonzero elements - MATLAB
This MATLAB function returns a vector containing the linear indices of each nonzero element in array X.
🌐
Columbia University
ee.columbia.edu › ~marios › matlab › Matrix Indexing in Matlab.pdf pdf
Digest Article: Matrix Indexing in MATLAB 2002 Issues September July May March
indexing, you use a single, logical array for the matrix subscript. MATLAB extracts the matrix · elements corresponding to the nonzero values of the logical array. The output is always in the form · of a column vector.
🌐
MathWorks
mathworks.com › matlabcentral › answers › 477641-index-vector-operation-in-matlab
Index Vector Operation in Matlab - MATLAB Answers - MATLAB Central
August 26, 2019 - Please restate your question. What do you mean by "get element C by index in vector A(b)"? Are you trying to do something like A(b)(2) to get at the 2nd element of C directly? If so, you cannot use that syntax in MATLAB.
🌐
Matlabsolutions
matlabsolutions.com › documentation › matlab-basics › array-indexing.php
Array Indexing - MATLAB & Simulink
For example, check which elements ... you want to find the values of the elements that are not missing. Use the ~ operator with the index vector ind to do this....
🌐
Stack Overflow
stackoverflow.com › questions › 71485620 › indexing-vectors-in-matlab
python - Indexing vectors in Matlab - Stack Overflow
Indices in MATLAB start at 1 rather than 0 like in other programming languages. Change to x_temp=x(1) ... Also it is length not lenght and if you want to index over the values in x, why are you using the length of t as the end of the for loop?