How to normalize 60x3 vector to zero mean and unit variance
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
Share a link to this question
I have vector size of 60x3 in an excel sheet, I need to find the zero mean and unit variance of all the values in that sheet and write back the result into another excel sheet. Can u please help me in writing the code.
Accepted Answer
Walter Roberson
on 16 Jun 2015
New_Array = (The_Array - mean(The_Array(:))) . / var(The_Array(:));
This assumes that the array as a whole is to have zero mean and unit variance, rather than each row or column to independently have zero mean and unit variance. If you want the columns done independently:
(The_Array - repmat(mean(The_Array), size(The_Array,1), 1)) ./ repmat(var(The_array), size(The_Array,1), 1);
7 Comments
Roger Stafford
on 16 Jun 2015
It should be
New_Array = (The_Array - mean(The_Array(:))) . / std(The_Array(:));
to get unit variance or unit standard deviation which is the same thing.
krishnasri
on 16 Jun 2015
D=xlsread('30Aed.xlsx');
New_Array = (D - mean(D(:))) . / std(D(:));
xlswrite('30Anorm',New_Array);
when i write the above code, it is giving an error message: Unexpected MATLAB operator . in line 2.. can u please help me resolve this
Walter Roberson
on 16 Jun 2015
New_Array = (D - mean(D(:))) ./ std(D(:));
I was writing on my phone, which loves to add extra spaces :(
krishnasri
on 17 Jun 2015
I didn't get your answer. can you please write it clearly..
Walter Roberson
on 17 Jun 2015
D=xlsread('30Aed.xlsx');
New_Array = (D - mean(D(:))) ./ std(D(:));
xlswrite('30Anorm',New_Array);
The only difference from what you had is to change the ". /" to "./" with no space.
krishnasri
on 17 Jun 2015
Okay got it.. Thanq...
Luis
on 15 Aug 2016
Actually you should divide by the standard deviation (std), not the variance (var)
(The_Array - repmat(mean(The_Array), size(The_Array,1), 1)) ./ repmat(std(The_array), size(The_Array,1), 1);
More Answers (0)
Categories
Find more on ANOVA in Help Center and File Exchange
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)