How can I represent the mean in figure

조회 수: 2 (최근 30일)
will99
will99 2019년 4월 11일
댓글: Star Strider 2019년 4월 11일
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

답변 (2개)

Star Strider
Star Strider 2019년 4월 11일
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
will99
will99 2019년 4월 11일
편집: will99 2019년 4월 11일
I'm trying to perform PCA without PCA matlab function and the first step was to get the mean of the vector nad substract it from the corrsponding data so it can have mean of zero I want to check if the new data have mean of zero so I want to know how can I plot it like the one in the example
Star Strider
Star Strider 2019년 4월 11일
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
Steven Lord 2019년 4월 11일
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)
  댓글 수: 1
will99
will99 2019년 4월 11일
yeah I want to plot the data before and after it got centered and shifted

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by