Theorical Question About Making Matlab Read Graphic

Let's say we have a graphic which consinst of x axis and y axis, but the shown lines in graphic are gathered from many experimental data's and we can't reach to those informations. So we are left with only graphic. To make situation worse we just have pdf version of the graphic.
In this case, how can we make a program which will read values from this graphic?
The question might be awkward. Im die-hard newbie in programming. I just wanted to ask and see what you guys would think about this.

 Accepted Answer

Click on this link to launch a File Exchange search for functions that scan and import data from a printed plot. One popular file appears to be GRABIT.

9 Comments

You are a true legend ... saviour of newbies
Thank you!
I very much appreciate your compliment!
I used the GRABIT. It works like a charm. The question I ask will follow up with the how to make matlab read the graph we created with Grabit toolbox. We need to gether x values corresponding to y values or vice versa
A function I wish I had written!
I have no experience with GRABIT, so I cannot help you with that.
What graph did you create, and how did you create it? If you had the data to create the graph, you should be able to use them directly. If you created a .fig file, those data are also possible to retrieve, although it requires a bit of code to do it.
This is the graph that I'm trying to convert and result is in the attatchment (see Fig1.fig).
But I couldn't find a solution for extracting 5 line separetly so I create new one with only 1 line (see Fig2m005.gif).
I found code for getting the points in (x,y) format like so; but I need like every possible point to make iterations later on, but in this case I just have 42 points. I need interp1 help I guess, I started to search that topic I will update if I solve it.
clear all;
close all;
clc;
h=openfig('Fig2m005.fig');
h=findobj(gca,'Type','line');
x=get(h,'Xdata');
y=get(h,'Ydata');
A=[];
A(:,1)=x;
A(:,2)=y;
dlmwrite('m005.txt',A,',');
And again Star Strider comes to help in another post,
x_i = 0:0.0001:0.02;
y_i = interp1(x, y, x_i, 'linear');
Solves my problem what a guy ...
The limitation on the points may be the result of the native figure resolution. There is likely nothing you can do about that.
Two options for creating more points from your available data:
xv = linspace(min(x), max(x), 150); % Linear Vector
yv = interp1(x, y, xv, 'linear'); % Interpolation (Option #1)
B = polyfit(x, y, 3); % Polynomial Fit (Option #2)
yv = polyval(B, xv); % Polynomial Fit (Option #2)
figure
plot(x, y, '.', xv, yv, '-r')
grid
I would not normally suggest interpolating either using interp1 or polyfit/polyval, however this may be appropriate for what you want to do. (I would not use more than a 3-degree polynomial fit.)
The ‘Fig1.fig’ figure appears to have all the lines, so you can select them and do the same sort of interpolation. It would likely be best to use the same ‘xv’ for all of them, since all the interpolated dependent variable values would then have the same independent variable values. (It does not need to be the same ‘xv’ I chose here. Choose the start-end and vector-size values that best fit your needs.)
Note: a while back I went through and tagged all of the File Exchange submissions on this topic, all with the tag "digitize". So you can find a variety of similar programs by searching on https://www.mathworks.com/matlabcentral/fileexchange/?term=tag:%22digitize%22
@Walter — I wasn’t aware of that! Thank you!

Sign in to comment.

More Answers (0)

Categories

Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!