필터 지우기
필터 지우기

How to calculate average of each column on a test file

조회 수: 1 (최근 30일)
Naomi Penelope
Naomi Penelope 2021년 7월 8일
댓글: Steven Lord 2021년 7월 8일
How do i calculate the average of each column from a text file, and after having the two average of X,Y coordinates how do I plot the point

답변 (1개)

Steven Lord
Steven Lord 2021년 7월 8일
Use the mean function.
Call the plot function.
  댓글 수: 2
Naomi Penelope
Naomi Penelope 2021년 7월 8일
I was able to find the average. but how do i plot a single point with x and y coordinates?
Steven Lord
Steven Lord 2021년 7월 8일
There are several different ways. Since in the case you describe your single point is unlikely to be exactly one of the points in your data set a simple way is to use hold on.
xy = rand(10, 2);
m = mean(xy, 1);
scatter(xy(:, 1), xy(:, 2), 'ro'); % You could also use plot here
hold on % So the subsequent plot call doesn't reset the axes
plot(m(1), m(2), 'kx')
Alternately you could use one call to plot to create two lines.
figure
plot(xy(:, 1), xy(:, 2), 'ro', m(1), m(2), 'kx')

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by