I would like to know how I could use the the values for one function to another.

1 回表示 (過去 30 日間)
Harjinder Singh Pabla
Harjinder Singh Pabla 2015 年 8 月 15 日
I would like to know how I could use the the values for num, den and sys I have in function untitled_OpeningFcn and use them on the pushbutton1_Callback function for the graphs and setting of the values of the text boxes.
function untitled_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
if strcmp(get(hObject,'Visible'),'off')
t = 0:0.25:7;
y = sin(t);
plot(t,y)
end
num = input('Enter coefficients of numerator: ');
den= input('Enter coefficients of denominator: ');
sys = tf([num],[den]);
display('Your transfer function is: '); sys
function pushbutton1_Callback(hObject, eventdata, handles)
if true
end
axes(handles.axes1);
cla;
set(handles.numtxt, 'String', num2str(num));
set(handles.dentxt, 'String', num2str(den));
popup_sel_index = get(handles.popupmenu1, 'Value');
switch popup_sel_index
case 1
pzmap(sys);
case 2
rlocus(sys);
case 3
nyquist(sys);
case 4
bode(sys);
end

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 8 月 15 日
  1 件のコメント
Harjinder Singh Pabla
Harjinder Singh Pabla 2015 年 8 月 15 日
I added global num den inside the first function and then I added handles.num and den.
num = input('Enter coefficients of numerator: ');
den = input('Enter coefficients of denominator: ');
sys = tf([num],[den]);
display('Your transfer function is: '); sys
handles.num = num;
handles.den = den;
num = handles.num;
den = handles.den;
sys = tf(num,den);
g = ilaplace(1/s^3);
set(handles.text9, 'String', char(g));
set(handles.numtxt, 'String', num2str(num));
set(handles.dentxt, 'String', num2str(den));

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by