Workaround for subscript indices being non-integers and non-logicals
Show older comments
Hello,
I'm trying to return a submatrix with all rows that have a matching column value, but I'm receiving this error: Subscript indices must either be real positive integers or logicals.
The error is in line 22 of the attached code. I cannot round my array values to an integer, and I'm not sure if there is a more obvious or efficient way of sorting my data by a column value (column 5), reporting the median of column 2 values (distances) for all rows with matching values in column 1 (data from the same time point).
I am looking for advice on how to write the given function to do what I described above without indexing into a matrix using matrix with nonintegers. I am relatively new to MATLAB and there is likely a more efficient way to execute this, but I'm not sure what question to ask yet.
Please let me know if I can provide more information. Thank you for any help.
Accepted Answer
More Answers (1)
Steven Lord
on 25 Apr 2017
0 votes
There's no such thing as the 1.5th element of a vector or matrix. Perhaps you want to perform interpolation instead of or in addition to indexing?
Categories
Find more on Matrices and Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!