How can I represent the mean in figure
2 views (last 30 days)
Show older comments
basically I have this code to de center the data by shifting it which do the following
find the mean of each vector and substract the mean from the corrsponding data
I want to represent the data in figure how can I do that ?
f = xlsread('data.xlsx');
s= size(f,2);
m = zeros(size(f));
for i = 1:s
m(:,i) = f(:,i)-mean(f(:,i));
end
0 Comments
Answers (2)
Star Strider
on 11 Apr 2019
You are taking the mean of each column of ‘f’, which is what the mean function does by default.
Try this:
m = f - mean(f)
Experiment to get the resullt you want.
4 Comments
Star Strider
on 11 Apr 2019
Assuming ‘f’ is an (Nx2) matrix, I would do this:
m = f - mean(f);
figure
plot(m(:,1), m(:,2), '+')
You can then use the MATLAB cov and eig functions to get the covariance matrix and its eigenvalues.
Steven Lord
on 11 Apr 2019
You can 'center' your data using the normalize function.
As for "represent the data in figure" do you mean you want to plot the centered data? If not can you say more about what type of visualization you want to create?
dicerolls = randi(6, 1, 100);
centeredDicerolls = normalize(dicerolls, 'center');
plot(centeredDicerolls)
Although for rolling six-sided dice, you may want to subtract off the theoretical mean of 3.5 instead of the mean of your set of rolls.
dicerollsMinus3p5 = normalize(dicerolls, 'center', 3.5);
plot(dicerollsMinus3p5)
See Also
Categories
Find more on Axis Labels 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!