How to replace some values in a matrix?
1 回表示 (過去 30 日間)
古いコメントを表示
I have x=16 * 16 matrix of double values. i need to figure out consecutive values of 'x' which are less than 150 and replace them with the original value plus(+) 8.
0 件のコメント
採用された回答
Stephen23
2017 年 5 月 1 日
編集済み: Stephen23
2017 年 5 月 1 日
>> x = randi(200,16,16);
>> idx = x<150;
>> x(idx) = x(idx)+8;
Very basic MATLAB operations, such as logical indices, as introduced in the Getting Started tutorials, which are highly recommended for all beginners:
3 件のコメント
Image Analyst
2017 年 5 月 1 日
How are you defining consecutive? MATLAB goes row by row (down rows), then over to the next column and down its rows. Is that your definition? If so, then is the last element in column 2 consecutive with the first element in column 3?
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!