live scripts and messages

조회 수: 11 (최근 30일)
Nick Pappas
Nick Pappas 2020년 3월 10일
댓글: Nick Pappas 2020년 4월 6일
Hi guys, I have a live script and i want to add a code to show me in real time when a value (from the signal) is above my threshold and pop up a message.
My code runs into a "while figure is open".
Those peaks around 1.2m , 2.7m and 3.6m are objects. Lets say that i want to set the threshold around 0.01.
What i want is:
(lets do this about amplitude first).
a) to get back a message that says " There is an object " .
b) to get a 2nd message that says " There is an object at X meters ".
If anyone can help i would appreciate it a lot.
Thank you for your time guys !
-Nick
This is a photo of my signal
1st figure is amplitude
2nd figure is Phase
while ishandle(fh)
[contentID,data_length,info,data] = xep.read_message_data_float();
if ~mod(info,1000)
% Every 1000th frame, output queue to give indication if plotting
% is lagging behind.
disp(['Number of data float messages in queue: ' num2str(xep.peek_message_data_float())]);
end
% Generate IQ vector.
i_vec = data(1:data_length/2);
q_vec = data(data_length/2+1:data_length);
iq_vec = i_vec + 1i*q_vec;
% Update data in handles for plotting.
ph_amp.YData = abs(iq_vec);
ylim(ax_amp,[0 max([0.03 max(abs(iq_vec)) + 0.01])]);
th_amp.String = ['Baseband amplitude - frameCounter = ' num2str(info)];
ph_phase.YData = atan2(q_vec,i_vec);
th_phase.String = ['Baseband phase - frameCounter = ' num2str(info)];
drawnow;
end

답변 (2개)

Jared MacDonald
Jared MacDonald 2020년 4월 2일
Hi Nick,
You can animate plots in the Live Editor if you are using R2019b or later. Please see the release notes for more information and an example of how to do it. If you are using R2019a, you must enable animations:
>> s = settings;
>> s.matlab.editor.AllowFigureAnimation.PersonalValue = true;
If you want some sort of alert when a condition is met, you can just use more disp statements or perhaps the msgbox command. Please let me know if this answers your question.
Jared
  댓글 수: 1
Nick Pappas
Nick Pappas 2020년 4월 6일
Yeah it helps.
Thanks a lot Jared !!

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


Jared MacDonald
Jared MacDonald 2020년 4월 2일
Hi Nick,
You can animate plots in the Live Editor if you are using R2019b or later. Please see the release notes for more information and an example of how to do it. If you are using R2019a, you must enable animations:
>> s = settings;
>> s.matlab.editor.AllowFigureAnimation.PersonalValue = true;
If you want some sort of alert when a condition is met, you can just use more disp statements or perhaps the msgbox command. Please let me know if this answers your question.
Jared

카테고리

Help CenterFile Exchange에서 Direction of Arrival Estimation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by