So guys I got the following problem:
I got a .fig 2D picture (actual picture based on data, not a simple 2D plot) with a colorbar from somebody else.
I want to write code that opens the picture and writes out all the data for me in a 2D Matrix.
I tried some of the Code that floats around the Internet, but nothing seemed to be working well for me.
Do you guys have any idea on how to do this ?
Edit: I attached an pcolor plot to show what it kinda looks like (I do not want to get in trouble for showing the real picture)

1 comentario

Walter Roberson
Walter Roberson el 20 de Abr. de 2018
Which plotting routine was used to create the figure? image, surface, contour, mesh, patch,...

Iniciar sesión para comentar.

 Respuesta aceptada

Guillaume
Guillaume el 20 de Abr. de 2018

0 votos

If you do have a pcolor plot, then your figure axis should contain a surface objet whose CData property should be the original data:

hfig = openfig(yourfigfile);
hsurf = findobj(hfig.Children, 'Type', 'surface');
originaldata = hsurf.CData;

5 comentarios

Philipp Heinrich
Philipp Heinrich el 20 de Abr. de 2018
Editada: Philipp Heinrich el 20 de Abr. de 2018

Not sure if it is actually pcolor (at least your code did not work, because the hsurf only shows "0x0 GraphicsPlaceholder). Here is an image of what I am working with.

Walter Roberson
Walter Roberson el 20 de Abr. de 2018
Try changing the 'surface' to 'image'
Philipp Heinrich
Philipp Heinrich el 20 de Abr. de 2018
nice it works. thank you guys for helping me this fast. really appreciate it.
Nicholas1900
Nicholas1900 el 26 de Jul. de 2018
hi, I have tried your code and changed 'surface'to 'image'. It doesn't work. The error message shows 'Attempt to reference field of non-structure array.
Error in data_extract_figure (line 10) hsurf = findobj(hfig.Children, 'Type', 'mesh');'
Walter Roberson
Walter Roberson el 26 de Jul. de 2018
Yiqing Meng: you appear to be using a MATLAB version that is R2014a or earlier.
You can use
hsurf = findobj(hfig, 'Type', 'surface');

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 20 de Abr. de 2018

Comentada:

el 26 de Jul. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by