trying to change negative values to 0 and positive to 1

44 ビュー (過去 30 日間)
Ayesha Punjabi
Ayesha Punjabi 2019 年 2 月 18 日
編集済み: per isakson 2019 年 2 月 18 日
  • i want to change all the positive number in voltsadd matrix to 1 and negative to 0
  • I am using a(a<0) = 0 command but its not working
  • here is the sample of my code
  • voltsadd_val = volts_add;
  • voltsadd_val(voltsadd_val<0) = 0;
  • voltsadd_val(voltsadd_val>0) = 1;
in the image below 12 bit is negative but its not working properly it always shows 1 as the output. Kindly help i dont understand where am i going wrong
matlab.JPG

回答 (1 件)

per isakson
per isakson 2019 年 2 月 18 日
編集済み: per isakson 2019 年 2 月 18 日
The problem is somewhere else
>> volts_add = randn(1,6);
>> volts_add( volts_add <= 0 ) = 0
volts_add =
0.5377 1.8339 0 0.8622 0.3188 0

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by