How do I display a graph with a calculate function in GUI?
古いコメントを表示
I'm developing a GUI in MATLAB trying to display a graph of concentration with respect to time.
I have coded a function that will calculate my concentration and I have made a button known as 'Calculate' which display the outcome after I input a few variables.
Now I want to make another button called 'Display' so when I push it, it will generate a plot with concentration to time.
I can't seem to find any info on this, any help would be great.
2 件のコメント
Arturo Moncada-Torres
2011 年 8 月 10 日
Bastion 1 day ago
Here is what I have done:
% --- Executes on button press in Button_CALC_C.
function Button_CALC_C_Callback(hObject, eventdata, handles)
A = get(handles.input_A,'String');
B = get(handles.input_B,'String');
X = get(handles.input_X,'String');
T1 = get(handles.input_T1,'String');
T2 = get(handles.input_T2,'String');
sum1 = str2num(A) + str2num(B)*str2num(X) + str2num(T1)^2;
C1 = num2str(sum1);
set(handles.text_C1,'String',C1);
guidata(hObject, handles);
sum2 = str2num(A) + str2num(B)*str2num(X) + str2num(T2)^2;
C2 = num2str(sum2);
set(handles.text_C2,'String',C2);
guidata(hObject, handles);
% --- Executes on button press in Button_Plot_TvC.
function Button_Plot_TvC_Callback(hObject, eventdata, handles)
axes(handles.T_C_Plot);
x = T1:1:T2; % [I WONDER WHY THIS LINE DOESN'T WORK? I WANT TO PLOT THE RANGE BETWEEN T1 AND T2 WITH THE RANGE BETWEEN C1 AND C2 FROM THE CODE IN THE PREVIOUS BUTTON]
y = C1:1:C2; % [I hope someone can help]
plot (x,y);
title('Time vs Concentration');
xlabel('Time');
ylabel('Concentration');
guidata(hObject, handles);
VISHWAS CHAVAN
2017 年 1 月 23 日
Hello, Give the handle command for every plot command like plot(handles.Tag name of plot,x,y); same for the title and other command give the handle of the plot.
採用された回答
その他の回答 (2 件)
Arnaud Miege
2011 年 8 月 3 日
0 投票
You need to add a set of axes to your GUI and plot the data on the axes. Have a look at GUI with Multiple Axes in the documentation for an example of this (using GUIDE).
HTH,
Arnaud
Bastion
2011 年 8 月 10 日
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!