Statistical calculation from the plot function

1 view (last 30 days)
Hidd_1 on 13 Jan 2022
Commented: Adam Danz on 13 Jan 2022
I created a plot function in an App:
like this
I would like to do statistical clculation like (Mean, root mean...etc) by using the data from the plot, how can I do that?
I would appreciate any tip, and Thanks in advance!

Accepted Answer

Adam Danz
Adam Danz on 13 Jan 2022
If you have the variables app.Tempreture_In, etc..., why not use them to compute the statistics?
If you only have the figures in a .fig file, you can get the (x,y) values by searching for the axes children.
% Open figure
fig = gcf();
ax = gca(fig); % assuming the figure has 1 axes, otherwise, select the axes
objs = ax.Children; % object handles like lines, scatter, etc
x = objs(1).XData; % x-values for the first object
y = objs(1).YData; % y-values for the first object.
Adam Danz
Adam Danz on 13 Jan 2022
Now your goal is more clear.
This answer provides a demo that shows how a user can draw a temporary rectangle in the axes to select a range of data. It returns the (x,y) coordinates of the selected data which you can use to compute statistics.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!