how can i assign few different calculation for a single pusshbutton
古いコメントを表示
hye. i have to design a program to calculate the Op-amp circuits's Voltage gain.here is a brief idea of how this program should be. when the user initiates the program, there will be a popupmenu (with three different choices or types of circuits), three edit_text inputs and a calculate_pushbutton. user selects the type of circuit in the popupmenu and keys in the 3 different values example like A B C. hw can i program the code below to have it calculate the values using different formulas with respect to the circuit type. example like if the user selects circuit one and keys in the value the calculate_pushbutton should calculate using the formula A/B. and if user selects circuit 2, A*C. i have done the program to get data from user in the edit_Text. and also a reset button. but now the problem is how can i assign three different formulas in the calculate_pushbutton. below is the codings i made to calculate. but it doesnt work.
switch get(handles.popupmenu,'Value')
case 1
A = get(input1_editText,'String');
B = get(input2_editText,'String');
C = get(input3_editText,'String'));
total = str2num(A)/str2num(B);
answer=num2str(total);
set(handles.answer_staticText,'String',answer;
case 2
A = get(input1_editText,'String');
B = get(input2_editText,'String');
C = get(input3_editText,'String'));
total = str2num(A)*str2num(C);
answer=num2str(total);
set(handles.answer_staticText,'String',answer;
set
otherwise
end
thank you for your help
採用された回答
その他の回答 (1 件)
nl2605
2013 年 7 月 19 日
0 投票
Follow this link to use pop up menus the right way.
It should work.
Also, if you want to dispay data in static text use:
set(handles.statictext,'String',answer);
Hope this helps.
9 件のコメント
nl2605
2013 年 7 月 19 日
You can put the answer using the 'tag' of your static text which is answer_staticText so it will be set(handles.answer_staticText, 'String', answer);
hardip
2013 年 7 月 19 日
nl2605
2013 年 7 月 19 日
what error are you getting when you press the button?
hardip
2013 年 7 月 19 日
hardip
2013 年 7 月 19 日
hardip
2013 年 7 月 19 日
nl2605
2013 年 7 月 19 日
:D No problem..
カテゴリ
ヘルプ センター および File Exchange で Specialized Power Systems についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!