Gui plot using Guide
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all,
I got some help with a code that lets me plot a variable in real time. However, I am having problem plotting 2 variables or inputs on th same plot. When I try to plot both inputs, it somehow combines the value and plots a single point for both. Not as famaliar with this plot method and not a 100% sure if it's even possible to do what I'm trying to.
Does you all have suggestions or other things to try?
Please let me know.
Thanks.
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.edit1.String = str2double(string(handles.dev.Query('SENS1:CORR:OFFS?'))); %Grab channel offset
handles.edit2.String = str2double(string(handles.dev.Query('SENS2:CORR:OFFS?'))); %Grab channel offset
grab_max = [];
grab_max_time = datetime();
hPlot = plot(NaN, NaN, '--*');
hasPlotBeenUpdated = false;
while handles.pushbutton2.Value == 1
grab_max= strsplit((string(handles.dev.Query('FETC1:ARR:CW:POW?'))),','); %Fetch data from PM and convert to string
grab_max = str2double(grab_max(4)); %Average Power - Convert String to Number and place in array
grab_max_time = datetime('now');
grab_max_t = datenum(grab_max_time);
pause(str2double(handles.edit3.String))
hold on
if ~hasPlotBeenUpdated
hasPlotBeenUpdated = true;
set(hPlot,'XData',grab_max_t,'YData',grab_max);
handles.grab_max = grab_max;
else
xdata = [get(hPlot,'XData'), grab_max_t]; % update the x-data
ydata = [get(hPlot,'YData'), grab_max]; % update the y-data
set(hPlot, 'XData', xdata, 'YData', ydata);
end
end
hold off
13 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Graphics Object Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!