Replace Values using For Loops

10 ビュー (過去 30 日間)
Angie
Angie 2018 年 2 月 8 日
編集済み: Birdman 2018 年 2 月 8 日
I am brand new to Matlab-I have a data matrix that is 128x128 and I would like to use a for loop to access every element of the data matrix, and replace every value higher than 60 with 1 and every value less than 60 by 0. I would appreciate your help. Thanks!

採用された回答

Birdman
Birdman 2018 年 2 月 8 日
編集済み: Birdman 2018 年 2 月 8 日
You don't need a for loop for this.
a=randi([1 120],128,128);%demo data
a(a>60)=1;
a(a<=60)=0;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by