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

1 Ansicht (letzte 30 Tage)
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

Antworten (1)

Walter Roberson
Walter Roberson am 15 Aug. 2015
  1 Kommentar
Harjinder Singh Pabla
Harjinder Singh Pabla am 15 Aug. 2015
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));

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by