How to read every i data in the UIAXES plotted data ?

Hi All
I have got a plot in my aap designer window, and after plotting some 2D data on it, I want to read and save only some specific data from this plot and not whole of it how do I do that
app.UIAxes.Children(i).YData = somefunction(b, a, app.UIAxes.Children(i).YData);
or somehow I should have access to numerical values in YData
I am trying the following but not succeeding, I have more than one plot
for i=1:numel(app.UIAxes.Children)
app.fitY = [app.fitY; app.UIAxes.Children(i).YData];
app.fitt = [app.fitt; app.UIAxes.Children(i).XData];
assignin('base','appdatay',app.UIAxes.Children(i).XData)
assignin('base','appdatax',app.UIAxes.Children(i).YData)
app.UIAxes.Children(i).YData = app.UIAxes.Children(i).YData(1:redrate:numel(app.fitY));
end

8 Comments

p.s : I used assign in and I see appdatay and appdatax have different values. the x values are correct and equal to the row numbers of the x data, but not the y data. it is somehow much less
farzad - from your comment, ...I have got a plot in my aap designer window, and after plotting some 2D data on it..., why not just use that data which you used to create the plots rather than trying to extract it from the axes children?
Thank you , because I have a list box, I click on the file name and it leads to plotting in the axes. later I want to press a push button that operates on this plot and changes the plot. it worked fine on filtering these plots, but now I wanted to somehow sample my data
Specially when I hit the push button , I do not think that I can know on which file I am pointing in the list box right. It might be better to operate on UIAxes data.
I would really appreciate if you could tell me why the data readings using the above lines never match in their X and Y. every time I hit the push button for the same plot I get a different reading
even when I do
for i=1:numel(app.UIAxes.Children)
app.fitY = [app.fitY; app.UIAxes.Children(i).YData];
app.fitY =app.fitY (1:redrate:numel(app.fitY));
assignin('base','appfitY',app.fitY)
% app.fitt = [app.fitt; app.UIAxes.Children(i).XDATA];
% assignin('base','appdatax',app.UIAxes.Children(i).XData)
% assignin('base','appdatay',app.UIAxes.Children(i).YData)
% app.UIAxes.Children(i).YData = app.UIAxes.Children(i).YData(1:redrate:numel(app.fitY));
end
I get the error
Error using vertcat
Dimensions of arrays being concatenated are not consistent.
yet Matlab generates the app.fitY parameter in base
nobody knows the answer ?
I am stuck in an urgent situation
farzad - you may need to show some or all of your code. If you are using plot to plot the data, then just maintain/save the handle to the plot (or the line object depending upon your version of MATLAB) and then use this handle to get the data you want. i.e.
hPlot = plot(1:10,11:20);
xData = get(hPlot, 'xdata');
yData = get(hPlot, 'ydata');

Sign in to comment.

Answers (0)

Categories

Products

Release

R2020a

Asked:

on 26 Nov 2020

Commented:

on 28 Nov 2020

Community Treasure Hunt

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

Start Hunting!