live scripts and messages

6 ビュー (過去 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 Center および File ExchangeGraphics Performance についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by