exctract data from 50 curves in .fig

1 visualización (últimos 30 días)
SCIUSCIA
SCIUSCIA el 30 de Jul. de 2022
Comentada: Star Strider el 30 de Jul. de 2022
I have a x-y plot including almost 50 curves.
I can extract the data for the single curve, but I get error if I use the 'for '. Indeed the final file is a collection of zeros
clear all;
close all;
clc;
fig=openfig('*.fig');
for i=1:50
dataObjsY = findobj(fig,'-property','YData');
yi = dataObjsY(i).YData;
dataObjsX = findobj(fig,'-property','XData');
xi= dataObjsX(i).XData;
A=[];
A(:,i)=xi;
A(:,i)=yi;
dlmwrite('datatoday.txt',A,',');
end

Respuesta aceptada

Star Strider
Star Strider el 30 de Jul. de 2022
The argument to openfig should be a single .fig file, so supply the appropriate information for ‘filename’ here.
Other than that, this should work —
fig=openfig('filename.fig');
Ax = gca;
Lines = findobj(gca, 'Type','Line');
for k=1:numel(Lines)
xv{k} = Lines{k}.XData;
yv{k} = Lines{k}.YData;
end
Assigning them to cell array elements is necessary because they may not all be differnt sizes or orientatioons.
Make appropriate changes to work with your files.
.
  4 comentarios
SCIUSCIA
SCIUSCIA el 30 de Jul. de 2022
yes, it runs now. resolved. thank you
Star Strider
Star Strider el 30 de Jul. de 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by