Filter löschen
Filter löschen

How to calculate average of each column on a test file

1 Ansicht (letzte 30 Tage)
Naomi Penelope
Naomi Penelope am 8 Jul. 2021
Kommentiert: Steven Lord am 8 Jul. 2021
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

Antworten (1)

Steven Lord
Steven Lord am 8 Jul. 2021
Use the mean function.
Call the plot function.
  2 Kommentare
Naomi Penelope
Naomi Penelope am 8 Jul. 2021
I was able to find the average. but how do i plot a single point with x and y coordinates?
Steven Lord
Steven Lord am 8 Jul. 2021
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')

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Graphics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by