MATLAB Answers

How to code an equation with a variable that implies to all cell and save in same size of input array (using nested for loop)

12 views (last 30 days)
AHMAD ASHRAF ABDUL HALIM
AHMAD ASHRAF ABDUL HALIM on 28 Feb 2021
Answered: dpb on 28 Feb 2021
data =xlsread('***');%%data is 100x1632 double
[m, n] = size(data);
min1 = min(data);
max1 = max(data);
for i=1:m
for x=1:n
MinMaxFunction=(data(i,x)-min1)/(max1-min1)*(1-(-1))+(-1);
end
end
  1 Comment
dpb
dpb on 28 Feb 2021
%%data is 100x1632 double
[m, n] = size(data);
min1 = min(data);
max1 = max(data);
Given array data is 2D, then min1, max1 are row vectors of length n.
So,what is wanted as a result of the normalization operation
MinMaxFunction=(data(i,x)-min1)/(max1-min1);
? To scale everything to the maximum overall in the entire array or each row to its max, range, ...???
Presuming it is overall, see Answer below, if something else, give us more specifics.

Sign in to comment.

Answers (1)

dpb
dpb on 28 Feb 2021
data =xlsread('***');
minOverall=min(data,[],'all');
rngOverall=range(data,'all');
data=(data-minOverall)/rngOverall;
Given earlier Comment caveat...

Tags

Community Treasure Hunt

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

Start Hunting!