Count curves on Matlab plot with specific name

조회 수: 27(최근 30일)
Tyler Murray
Tyler Murray 2017년 1월 18일
댓글: Tyler Murray 2017년 1월 18일
Is there a way to count how many curves are on a specific Matlab Figure? I define the name of plot as
figure('Name','Simulation', 'NumberTitle', 'Off')
Since I have multiple plots generated at various times I am unable to use gcf. What I would like to do is something like
to find all curves associated with the plot (or plots) named Simulation.
  댓글 수: 3
Tyler Murray
Tyler Murray 2017년 1월 18일
I saw the one suggestions of using
but as I said earlier I need to use that on all figures using one axis not necessarily the current axis.

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

채택된 답변

Greg Dionne
Greg Dionne 2017년 1월 18일
You can try
hFigure = findall(0,'type','figure','name','Simulation')
That should give you the handle to all figures with the name Simulation. you can then do:
hLines = findall(hFigure,'type','line')
which should give you all the lines.
If you don't like decorating your figures with unique names, you can also use the 'tag' property on your lines, axes, whatever and search for that. Nothing user-visible, just something you can use to search against.
  댓글 수: 1
Tyler Murray
Tyler Murray 2017년 1월 18일
You're the man Greg, thanks

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by