Shifting least negative value to zero

Hello
So i have a graph whose values run below 0. i want to make the least point on this graph start from zero so that the subsequent values change accordingly. say -60 is the least point.. it should be zero on the graph the -20 will be at 40 and so on. please help me out.
Thank you so much
Happy New Year

 採用された回答

KSSV
KSSV 2022 年 1 月 1 日
編集済み: KSSV 2022 年 1 月 1 日

0 投票

Let x be your data.
xnew = x-min(x) ;
Als have a loon on the function rescale.

5 件のコメント

siri meka
siri meka 2022 年 1 月 1 日
Hi
Thanks for responding. but i want to make minimum point as zero and retain the data
KSSV
KSSV 2022 年 1 月 1 日
[val,idx] = min(x) ;
x(idx) = 0 ;
KSSV
KSSV 2022 年 1 月 1 日
If you are talking about only changing the negative values;
idx = x < 0 ;
x(idx) = x(idx)-min(x) ;
siri meka
siri meka 2022 年 1 月 1 日
Thank You
Image Analyst
Image Analyst 2022 年 1 月 1 日
Or (another way) to clip all negative values at zero
x = max(x, 0);
Now negative values will be set to 0 and positive values will remain unchanged.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDiscrete Data Plots についてさらに検索

質問済み:

2022 年 1 月 1 日

コメント済み:

2022 年 1 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by