live scripts and messages
4 views (last 30 days)
Show older comments
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
0 Comments
Answers (2)
Jared MacDonald
on 2 Apr 2020
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
Jared MacDonald
on 2 Apr 2020
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
0 Comments
See Also
Categories
Find more on Graphics Performance in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!