- Create a figure window.
- Create a UI axes.
- Create an edit field component.
- Create a push button. Associate a call back function with input parameters – UI axes, edit field for the push event.
- In the call back function, parse the edit field and plot on the UI axes.
How to link a pushbutton with edit box and axes in MATLAB GUI. to plot graph with single pushbutton based on values written in edit box by user?
6 ビュー (過去 30 日間)
古いコメントを表示
i wanted to plot graph of AM(modulated and demodulated both graphs) signal using a pushbutton with the help of values entered in edit box by user in MATLAB GUI.
0 件のコメント
回答 (1 件)
Praveen Reddy
2023 年 3 月 15 日
Hi Mohit,
I understand that you want to plot a graph with the data entered by a user in an edit field of MATLAB GUI. Here are some steps you can follow:
Attaching a small code snippet for your reference.
function buttonPlot
% Create a figure window
fig = uifigure;
% Create a UI axes
ax = uiaxes('Parent',fig,...
'Units','pixels',...
'Position', [104, 123, 300, 201]);
edit1 = uieditfield(fig,'Position',[420, 180, 100, 32]);
% Create a push button
btn = uibutton(fig,'push',...
'Position',[420, 218, 100, 22],...
'ButtonPushedFcn', @(btn,event) plotButtonPushed(btn,ax,edit1));
end
% Create the function for the ButtonPushedFcn callback
function plotButtonPushed(btn,ax,edit1)
%Extract the values entered in edit field. Eg : 1 5 7 8 12
x_values=str2num(edit1.Value);
plot(ax,x_values);
end
To know more about “str2num”, please refer to the following MATLAB documentation:
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Interactive Control and Callbacks についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!