how to extract data from Matlab figure with stacked lines? (2024)

7 views (last 30 days)

Show older comments

Shaymaa Tahhan on 22 Feb 2024

  • Link

    Direct link to this question

    https://webchat.mathworks.com/matlabcentral/answers/2085643-how-to-extract-data-from-matlab-figure-with-stacked-lines

  • Link

    Direct link to this question

    https://webchat.mathworks.com/matlabcentral/answers/2085643-how-to-extract-data-from-matlab-figure-with-stacked-lines

Answered: Voss on 22 Feb 2024

  • intensity with lines.fig

Please I have tried alot with this code

open('spectrum.fig');

a = get(gca,'Children');

xdata = get(a, 'XData');

ydata = get(a, 'YData');

xdata1 = get(a(2), 'XData');

ydata1 = get(a(2), 'YData');

but it doesnt work correctly I just get the last line data?!

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

Answers (1)

Voss on 22 Feb 2024

  • Link

    Direct link to this answer

    https://webchat.mathworks.com/matlabcentral/answers/2085643-how-to-extract-data-from-matlab-figure-with-stacked-lines#answer_1414768

Open in MATLAB Online

  • intensity with lines.fig

f = openfig('intensity with lines.fig');

how to extract data from Matlab figure with stacked lines? (3)

lines = findall(f,'Type','line')

lines =

10×1 Line array: Line Line Line Line Line Line Line Line Line Line

xdata = get(lines,'XData'); % xdata: 10x1 cell array, each cell contains 1 line's XData

ydata = get(lines,'YData'); % ydata: 10x1 cell array, each cell contains 1 line's YData

If you know that the lines XData/YData are all row vectors of the same size (which they are in this case), it may be convenienet to concatentate them into a single matrix:

xdata = vertcat(xdata{:})

xdata = 10×8192

1.0e-11 * -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206 -0.6250 -0.6248 -0.6247 -0.6245 -0.6244 -0.6242 -0.6241 -0.6239 -0.6238 -0.6236 -0.6235 -0.6233 -0.6232 -0.6230 -0.6229 -0.6227 -0.6226 -0.6224 -0.6223 -0.6221 -0.6219 -0.6218 -0.6216 -0.6215 -0.6213 -0.6212 -0.6210 -0.6209 -0.6207 -0.6206

ydata = vertcat(ydata{:})

ydata = 10×8192

1.0e+00 * 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000

so that xdata(1,:) is the first line's XData, xdata(2,:) is the second line's XData, etc., etc.

0 Comments

Show -2 older commentsHide -2 older comments

Sign in to comment.

Sign in to answer this question.

See Also

Categories

MATLABProgrammingProgramming Utilities

Find more on Programming Utilities in Help Center and File Exchange

Tags

  • data import
  • figure data import

Community Treasure Hunt

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

Start Hunting!

An Error Occurred

Unable to complete the action because of changes made to the page. Reload the page to see its updated state.


how to extract data from Matlab figure with stacked lines? (4)

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom(English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

how to extract data from Matlab figure with stacked lines? (2024)

FAQs

How to extract results from MATLAB? ›

To save results, select the result in the Test Manager, in the Results and Artifacts pane, and click Export on the toolstrip.
  1. Select complete result sets to export to a MATLAB® data export file ( MLDATX ). Note. ...
  2. Select criteria comparisons or simulation output to export signal data to the base workspace or to a MAT-file.

How to extract xy data from MATLAB figure? ›

Open the figure:
  1. h = findobj(gca,'Type','line')
  2. x=get(h,'Xdata') ;
  3. y=get(h,'Ydata') ;
Feb 19, 2018

How to extract data from a file MATLAB? ›

Usually, the easiest way to import text data into MATLAB is to use the extractFileText function. This function extracts the text data from text, PDF, HTML, and Microsoft Word files. To import text from CSV and Microsoft Excel files, use readtable . To extract text from HTML code, use extractHTMLText .

How do you extract points from a graph? ›

You can use an OCR to extract the values and can even try fine-tuning it to capture the symbols. You can correlate the bounding boxes to find the values. Then you can use simple logic to capture the symbols and correlate them on the axis for the value. You can also use an LLM to understand the semantics of the chart.

How to export data from MATLAB figure to Excel? ›

To export a table in the workspace to a Microsoft® Excel® spreadsheet file, use the writetable function. You can export data from the workspace to any worksheet in the file, and to any location within that worksheet. By default, writetable writes your table data to the first worksheet in the file, starting at cell A1 .

How to extract features from dataset in MATLAB? ›

inputData = {t1,t2,t3}; features = diagnosticFeatures(inputData); For an example of generating code and validating the code with the original data, see Generate a MATLAB Function in Diagnostic Feature Designer. For an example that applies code to a new dataset, see Apply Generated MATLAB Function to Expanded Data Set.

How do I extract a field from a structure in MATLAB? ›

a = extractfield( S , name ) returns the field values specified by the field name of structure S .

How to extract elements from table in MATLAB? ›

Indexing with curly braces extracts data from a table and results in an array, not a subtable. But other than that difference, you can specify rows and variables using numbers, names, and data type subscripts, just as you can when you index using smooth parentheses. To extract values from a table, use curly braces.

How to extract table variables in MATLAB? ›

Dot notation, as in T. varname , extracts one variable. Curly braces, as in T{ rows , vars } , extracts an array from specified rows and variables. Parentheses, as in T( rows , vars ) , returns a table.

How to read a file in MATLAB line by line? ›

Description. S = readlines( filename ) creates an N-by-1 string array by reading an N-line file. S = readlines( filename , Name,Value ) creates a string array from a file with additional options specified by one or more name-value pair arguments.

How do I extract a data file? ›

Extracting data from a table or view to a . data file
  1. Right-click a table or view in the Data Source Explorer, and click Data > Extract. If you are in the Object List, right-click the table or view and click Unload > With SQL. ...
  2. Specify a name and location for the file. Specify delimiter options, and then click Finish.

What is the program to extract data points from a graph? ›

Opensource computer vision assisted software to help extract numerical data from images of plots, maps and much more.

How do I view data points in MATLAB? ›

To identify the values of data points in your chart, create data tips. Data tips appear temporarily as you hover over the data points in your chart. To display persistent (pinned) data tips, click one or more data points. Alternatively, select the data tips button in the axes toolbar and then click a data point.

Top Articles
Latest Posts
Article information

Author: Mrs. Angelic Larkin

Last Updated:

Views: 6157

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Mrs. Angelic Larkin

Birthday: 1992-06-28

Address: Apt. 413 8275 Mueller Overpass, South Magnolia, IA 99527-6023

Phone: +6824704719725

Job: District Real-Estate Facilitator

Hobby: Letterboxing, Vacation, Poi, Homebrewing, Mountain biking, Slacklining, Cabaret

Introduction: My name is Mrs. Angelic Larkin, I am a cute, charming, funny, determined, inexpensive, joyous, cheerful person who loves writing and wants to share my knowledge and understanding with you.