How to normalize data ?

Hi, I have data with dimension 1x25, where
x = rand(1,25);
D = size(x,2);
I'm trying using this code, but the result is NaN. Please help me, to fix my code. Thanks
for col = 1: D
x(:,col)=double(x(:,col)-mean(x(:,col)));
end
for col = 1: D
x(:,col)=double(x(:,col)/std(x(:,col)));
end

 采纳的回答

x = rand(1,25);
x = (x-mean(x))/std(x)

3 个评论

thanks for the answer sir, but when I use in matrik with size 220x25 dimension, I get error like this :
x = rand(220,25);
x = (x-mean(x))/std(x)
Error using -
Matrix dimensions must agree.
Stephan
Stephan 2018-12-16
编辑:Stephan 2018-12-16
Which Matlab release do you use? In 2018b the result is a 220x1 vector.
I used matlab R2015a

请先登录,再进行评论。

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by