How do you pull data from a text box, and set it to plot?
2 次查看(过去 30 天)
显示 更早的评论
Hello all, I have created a GUI that can do simple math by adding subtraction etc... and puts the results into a text box. What I want to do is take that single digit and plot it on a plane, I already know how to plot a graph if you hard type it in, but I want it to change with the calculated value. So I know it will be something like..
plot( function EXAMPLE, but I don't know how it goes after this.
I already have the push button to plot and the graph to have it plot on, I just need the correct coding to pull TEXT BOX A and graph that value!
Hope this makes sense
0 个评论
采纳的回答
Geoff Hayes
2014-10-15
Grant - presumably you are plotting the result of the calculation on an axes that is a part of your GUI. So in the callback to your push button, just do something like the following
function pushbutton1_Callback(hObject, eventdata, handles)
% get the data from text box A
data = str2num(char(get(handles.text1,'String')));
% do something with the data
% now plot it on the axes/graph
plot(handles.axes1,...);
The above assumes that you are using GUIDE to develop your GUI. The tag for your text box A is text1 and the tag for the axes is axes1.
5 个评论
Geoff Hayes
2014-10-16
I suspect that the way it is working now is that the previous points are being cleared out. If you want to keep them, then in the OpeningFcn of your GUI, you could do something like
hold(handles.axes,'on');
which will retain previous calls to plot for the specified axes (i.e. previous plots won't be deleted).
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!