I want to plot with the value of an Edittext
1 次查看(过去 30 天)
显示 更早的评论
Hi guys,
I'm currently working on a Guide, I have two Edittextboxes and two Pushbuttons. In the Edittextboxs I want to type in a value and plot some functions with one of the Pushbuttons. So I have to variables, in edittextbox input1 is x and in input2 is g. The range of g is between 0.1 and 1, but x is between 40 and 90.
I hope it's understandable. Thank you very much!
% --- Executes on button press in button1.
function button1_Callback(hObject, eventdata, handles)
% hObject handle to button1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
x = str2num(char(get(handles.input1, 'String'))); %I want to get the edittext (input1)
y1=(0.02049/0.4)*x;
y2=(g*60./(1+(1.331./(sqrt(0.0631*x./(83.17-x))).^3)));
y3=(g*60./(1+(1.331./(sqrt(0.0631*x./(83.17-x))).^3)))-(0.02049/0.4)*x;
y4=(0.02049/0.4)*x-(g*60./(1+(1.331./(sqrt(0.0631*x./(83.17-x))).^3)));
plot(x,y1,'r','LineWidth',2)
hold on
plot(x,y2,'c','LineWidth',2)
plot(x,y3,'g','LineWidth',2)
plot(x,y4,'b', 'LineWidth',2 )
title('metabolisches Profil','FontSize', 15)
xlabel('VO2', 'FontSize', 15)
ylabel('dLak/dmin','FontSize', 15)
legend( 'func.1','func.3','func.4','func.5','FontSize', 12)
axis([0 100 0 5])
0 个评论
采纳的回答
Nirav Sharda
2017-1-24
编辑:Nirav Sharda
2017-1-24
This is the callback function for the first edit text box.
function edit1_Callback(hObject, eventdata, handles)
% save the data from the edit text box in the handles structure in double format.
handles.in1 = str2double(get(hObject,'String'));
% Store the handles structure in hObject.
guidata(hObject,handles);
You will have a similar callback for the second edit box. Now the following is the code snippet for the push button callback.
function pushbutton1_Callback(hObject, eventdata, handles)
% get the previously stored data in myh variable.
myh = guidata(hObject);
% get the values of in1 and in2 in variables x and y. These values come from edit text boxes.
x = myh.in1;
y = myh.in2;
figure;
plot(x,y,'r','LineWidth',2);
I hope this helps !
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Data Preparation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!