我正在创建一个GUI,用于绘制输入数据中的Bode Plot。我有下面的代码,但它给了我一个我不明白的错误。如何在Matlab GUI中插入Bode Plot函数
function first_gui
%This gui plots a bode plot from a
%a Transfer function generated from the main plot
%Create a figure with the plot and others pushbutons
f = figure('Visible','on','Position',[360,500,600,400]);
hplot = uicontrol('Style','pushbutton','String','Plot','Position',[415,200,70,25],'Callback',@tf_Callback);
%Create an entering data to numerator
htext = uicontrol('Style','text','String','Entre com a função de transferência','Position',[320,350,250,15]);
hnum = uicontrol(f,'Style','edit','String','Enter TF numerator...','Position',[320,320,250,20]);
%Create an entering data to denominator
htext_2 = uicontrol('Style','text','String','Entre com a função de transferência','Position',[320,280,250,15]);
hden = uicontrol(f,'Style','edit','String','Enter TF denominator...','Position',[320,250,250,20]);
hfig = axes('Units','pixels','Position',[50,60,200,185]);
%Initialize the UI
f.Units = 'normalized';
hfig.Units = 'normalized';
hplot.Units = 'normalized';
hnum.Units = 'normalized';
hden.Units = 'normalized';
sys = tf(hnum,hden);
f.Name = 'Bode Plot';
%Function to plot Bode
function tf_Callback(source,eventdata)
bode(sys)
end
end
目前正出现在IDLE这些错误:
错误使用TF(线279) 为 “TF” 命令无效语法。输入“help tf”以获取更多信息。
Simple_Plot中的错误(第29行) sys = tf(hnum,hden);
未定义的函数或变量“sys”。
错误Simple_Plot/tf_Callback(36行) 波特(SYS)
错误而评估uicontrol回调