Extracting values from a matrix
4 次查看(过去 30 天)
显示 更早的评论
Hi Hello, i hope eveyrone is doing good, i have a matrix (6100,1000) and i would like to extract some values , the rows of my matrix contains values but most of it's -300, e,g first row ( -300 -300 -300 ......... -124 -300 -300 -300) so i would like to extract 10 values that are not equal to -300, but in the case where i dont have other values i can take -300 only to fill it, basically i would like to do this for my whole matrix
thank you
2 个评论
dpb
2022-5-13
You know what your intent is; we don't except by the description you post. There's too much not explained here -- for example, are you just wanting some number of values out of the total number that are in the file, selecting all of those that aren't -300 first irrespective of their position in the file? Or do you want the rows that have something other than -300 by row; a specific number of rows overall? Or...???
Give us a an example -- explain precisely what your expected output would be.
It would help to have a sample file -- attach a .mat file
采纳的回答
Image Analyst
2022-5-13
Do they need to be in any particular order? Otherwise just sort and take the first 10 elements. Like for a single row, do this:
sortedValues = sort(oneRow, 'descend');
first10 = sortedValues(1:10);
Can you supply a sample matrix?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!