extract specific values in a matrix
4 次查看(过去 30 天)
显示 更早的评论
Hello
I have a 104*14 matrix and I need to get some of the values in column 10 of this matrix which corresponds to values in first column that equal to 0.03.
How can I write that in matlab?
Thanks
0 个评论
采纳的回答
the cyclist
2019-8-28
编辑:the cyclist
2019-8-28
If A is your matrix:
A(find(A(:,10)==0.03,1),10);
You might need to be careful about getting an exact match with the floating-point value 0.03, and use some kind of tolerance instead.
For example:
A(find(A(:,10)>(0.03-1.e-9) & A(:,10)<(0.03+1.e-9),1),10);
Take a look at this documentation for eps (floating point relative accuracy) if you need to be more precise.
2 个评论
the cyclist
2019-8-28
Oh, sorry, I misread! I thought you needed the first value in column 10, rather than using the value from the first column. Glad to have helped despite my error.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!