Statistical calculation from the plot function

I created a plot function in an App:
like this
plot(app.UIAxes,app.Time,app.Tempreture_In,app.Time,app.Tempreture_out)
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!

 採用された回答

Adam Danz
Adam Danz 2022 年 1 月 13 日

0 投票

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.
Demo:
% 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.

4 件のコメント

Adam Danz
Adam Danz 2022 年 1 月 13 日
@Hidd_1's answer moved here as a comment
I would like to choose a range of the data visually to apply the statistical calculation, that's why I am looking for a way to selecte it from the graph and then compute.
Adam Danz
Adam Danz 2022 年 1 月 13 日
If you have the variables, then index them to your selected range. For example, if you want to compute the mean of y within the range of x=2 and x=10, then for the line produced by plot(x,y),
isInRange = x>=2 & x<=10;
mu = mean(y(isInRange))
Hidd_1
Hidd_1 2022 年 1 月 13 日
I would like to export the app as exe file, and the user select the data and process it without any coding.
How can I merge the code in a way that the user select the data and than click on a button for instance and than get the result?
Adam Danz
Adam Danz 2022 年 1 月 13 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

製品

リリース

R2020a

質問済み:

2022 年 1 月 13 日

コメント済み:

2022 年 1 月 13 日

Community Treasure Hunt

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

Start Hunting!

Translated by