我正在創建一個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回調