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

 채택된 답변

Star Strider
Star Strider 2022년 7월 30일

0 개 추천

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

SCIUSCIA
SCIUSCIA 2022년 7월 30일
Thank you.
I tried to run it, but it seems that there is a problem
Brace indexing is not supported for variables of this type.
Error in multiextract (line 8)
xv{k} = Lines{k}.XData;
I copied that (apparently incorrectly) from my archived code.
Try this instead —
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
.
SCIUSCIA
SCIUSCIA 2022년 7월 30일
yes, it runs now. resolved. thank you
Star Strider
Star Strider 2022년 7월 30일
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2022년 7월 30일

댓글:

2022년 7월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by