How to extract data from a plot (figure)

Hello!
I am trying to extract the data in my figure, when it gets "true" or "false". For example, the image below has a true at 0.4159 and a false at 0.9795. How can I extract this (can be through a script) to get these point all over the plot?
Thank you in advance!

댓글 수: 5

Mischa Kim
Mischa Kim 2021년 1월 8일
How did you create the plot?
Gustavo Araujo
Gustavo Araujo 2021년 1월 8일
I did a plot after a Simulink Simulation finished:
plot(Fault.time,Fault.signals.values)
and then reached the graph.
hello
the simple code below will give you the x data indexes when above or below a threshold
istrue = find(Fault.signals.values>0.5)
isfalse = find(Fault.signals.values<1e-3)
if you are interested in finding the rising and falling transition index , time and output values, you can use the attached function
level = 0.5;
[ind_pos,t0_pos,s0_pos,ind_neg,t0_neg,s0_neg] = crossing_V7(Fault.signals.values,Fault.time,level,'linear')
Gustavo Araujo
Gustavo Araujo 2021년 1월 8일
Thank you a lot! It worked on what I'm working on!
If I want to place the t0_neg and t0_pos inside another function, what's the right way to do this?
Mathieu NOE
Mathieu NOE 2021년 1월 11일
hello Gustavo
glad it meets your needs
you can create your own function that use's the crossing function I sent you (call it inside your own function and pass the arguments).

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

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 1월 8일

0 개 추천

You would process the data used to create the plot, not the plot itself. Look at your plot and see if you can identify some characteristic you could use to detect when the signal switches to true and when it switches to false.
I would probably try something using diff(Fault.signals.values), since a change of +1 indicates a switch from False to True, while a change of -1 indicates a switch from True to False.
See this answers post as well.

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

질문:

2021년 1월 8일

댓글:

2021년 1월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by