Represent array in percentage

14 ビュー (過去 30 日間)
Nithesh Thakku Krishnamoorthy Ganesan
I have an array, I want to display the array in percentage such that the maximum value in the array is displayed as 100% and the minimum value as 0%. How do i this?
My array is [2.5 2.6 ........ 4.2]
I want to it to be displayed where 2.5 becomes 0% and 4.2 becomes 100%

採用された回答

Joseph Cheng
Joseph Cheng 2021 年 6 月 14 日
編集済み: Joseph Cheng 2021 年 6 月 14 日
you would take your array, subtract the minimum, then divide by the resulting maximum x 100
x = [2.4:.4:4.2];
x = x-min(x);
disp(x)
0 0.4000 0.8000 1.2000 1.6000
percX = x./(max(x(:)))*100
percX = 1×5
0 25.0000 50.0000 75.0000 100.0000
  1 件のコメント
Nithesh Thakku Krishnamoorthy Ganesan
Thank you for your help

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by