Extract data from MATLAB plots

조회 수: 9 (최근 30일)
Kash022
Kash022 2016년 3월 18일
답변: Ralf 2016년 3월 18일
Hello All, I have a figure from which I want to extract data. Please see figure. I need to find the average(y-axes values) for the x-axes between 100 and 400 and 700 and 2000. I have started with the following code snippet but how do I move ahead with this?
>> h=gcf;
>> axesObjs = get(h, 'Children'); %axes handles
dataObjs = get(axesObjs, 'Children');
>> objTypes = get(dataObjs, 'Type');
>> xdata=get(dataObjs,'XData');
>> ydata=get(dataObjs,'YData');
>> my_avg = mean(ydata, [100 400]);
Thanks!
  댓글 수: 1
Kash022
Kash022 2016년 3월 18일
I think I figured it out.
y1 = ydata(100:400);
x1= mean(y1);
Hope this is correct? Thanks!

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

답변 (1개)

Ralf
Ralf 2016년 3월 18일
Hi ksnf3000,
I doubt that this is correct. This would calculate the mean value of ydata between the 100th and 400th data point of ydata.
As far as I understand you want to calculate the mean value of ydata values, when the corresponding xdata values are between 100 and 400.
For this you would need the following
y1 = ydata((xdata>=100) & (xdata<=400));
x1 = mean(y1);

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by