failing to normalize columns of matrix from 0 to 1
Show older comments
for ii=[2 4 6 8 10 12 14 16 18 20 22 26]
n=(A-min(A(:,ii)))/(max(A(:,ii))-min(A(:,ii)));
end
I have a 526x26 matrix, and I need the data in the even-numbered columns to be between 0 and 1. Using the code above, I am getting numbers slightly above 1 (for example, 1.01977).
Accepted Answer
More Answers (1)
Image Analyst
on 12 Apr 2025
Try rescale
for ii = 2 : 2 : size(A, 2)
A(:,ii) = rescale(A(:,ii), 0, 1);
end
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!