MATLAB: How to extract x, y data values from matlab figure extractmatlab figure please find the attachment; in the figure, there are two data values. i need the x and y values of this data. Best Answer Open the figure:h = findobj(gca,'Type','line')x=get(h,'Xdata') ;y=get(h,'Ydata') ;(x,y) is your required data. Related SolutionsMATLAB: Retrieving data from many plots Already you have the data in hand. YOur xdata and ydata will be a cell with your required data. Check the below demo code:figurehold onfor i = 1:5 plot(rand(1,10));endh = gcf;axesObjs = get(h, 'Children'); dataObjs = get(axesObjs, 'Children');objTypes = get(dataObjs, 'Type');xdata = get(dataObjs, 'XData'); ydata = get(dataObjs, 'YData');% extract datafor i = 1:numel(xdata) fprintf('%d line data\n',i) ; xdata{i} ydata{i}end MATLAB: Data from figures without data The following code might help.% Open your figurefig = openfig('example.fig');% Find Xdata and YData objectsdataObjs = findobj(fig,'-property','YData');y1 = dataObjs(1).YData;dataObjs = findobj(fig,'-property','XData');x1 = dataObjs(1).XData; Related QuestionHow I can get data from plotHow to extract surface plot data from MATLAB figure
Best Answer