live scripts and messages
13 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/276285/image.png)
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 个评论
回答(2 个)
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
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!