How to remove certain value from array and reshape the array?

160 次查看(过去 30 天)
I want to delete every -120 value from S(i x j) and reshape the S without -120.
Only S(X, certain 'Y's) have this -120 value.
Any ideas?

回答(1 个)

Guillaume
Guillaume 2017-12-1
编辑:Guillaume 2017-12-1
Deleting arbitrary elements from an array will always automatically reshape it into a vector unless you explicitly delete entire rows, columns, pages, etc.
So:
S(S == -120) = [];
will delete all -120 values and reshape your array at the same time.

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!