How to normalize the values of matrix to make it greater than zero and less than one?

4 ビュー (過去 30 日間)
hello,
ho to normalize the values of a matrix to make it greater than zero and less than one?
regards,
  2 件のコメント
madhan ravi
madhan ravi 2018 年 10 月 23 日
See my answer below
Sarah A
Sarah A 2018 年 10 月 23 日
yes I am outside now, I need to try this on my laptop. thanks for answering I will accept the answer if it works.

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

採用された回答

Matt J
Matt J 2018 年 10 月 23 日
編集済み: Matt J 2018 年 10 月 23 日
B=(A-min(A(:)))/(max(A(:))-min(A(:))) ;
  4 件のコメント
Sarah A
Sarah A 2018 年 10 月 23 日
It works! thanks a lot :)
Walter Roberson
Walter Roberson 2018 年 10 月 23 日
delta = max(eps(A(:));
B=(A-min(A(:))+delta)/(max(A(:))-min(A(:))+delta) ;

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

その他の回答 (3 件)

madhan ravi
madhan ravi 2018 年 10 月 23 日
編集済み: madhan ravi 2018 年 10 月 23 日
Try :
Np = normalize(A,'norm',1) % A your matrix
  1 件のコメント
Sarah A
Sarah A 2018 年 10 月 23 日
編集済み: Sarah A 2018 年 10 月 23 日
This error occur:
Undefined function 'normalize' for input arguments of type 'double'.
when I searched about "normalized" function I got this:
function ydata = normalize(this,ydata,Xlims,varargin)
%NORMALIZE Scales Y data to normalized time data range.
%
% Input arguments:
% * YDATA is the Y data to be normalized
% * XLIMS are the X limits for the axes of interest
% * The last argument(s) is either an absolute index or a pair
% of row/column indices specifying the axes location in the
% axes grid.
% Author(s): P. Gahinet
[ns,ny,nu] = size(this.Amplitude);
if ny>0
[ymin,ymax,FlatY] = ydataspan(this.Time,this.Amplitude(:,varargin{:}),Xlims);
ydata = (ydata - (ymin+ymax)/2)/((ymax-ymin)/2+FlatY);
end
Copyright 1986-2004 The MathWorks, Inc.

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


Matt J
Matt J 2018 年 10 月 23 日
編集済み: Matt J 2018 年 10 月 23 日
delta=0.01;
B = rescale(A,delta,1-delta);
  1 件のコメント
Sarah A
Sarah A 2018 年 10 月 23 日
The same problem I got this error:
Undefined function 'rescale' for input arguments of type 'double'.

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


Matt J
Matt J 2018 年 10 月 23 日
  4 件のコメント
Sarah A
Sarah A 2018 年 10 月 23 日
no I want to normalize here where the output of normalization is greater than zero and less than one.
Matt J
Matt J 2018 年 10 月 23 日
But hopefully you can see now how vague that is. There are a million answers.

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

カテゴリ

Help Center および File ExchangeLinear Algebra についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by