The capacitor result is working
But the plot is giving an error and cannot draw gain vs freq
This is the code:
function calculate_button_Callback(hObject, eventdata, handles)
option = get(handles.r_values, 'value');
switch option
case 1
R = 1000;
case 2
R = 2000;
case 3
R = 3000;
case 4
R = 4000;
end
f_c = get(handles.fc_value,'string');
f_c = str2double(f_c);
c_value = 1 / (2*pi*R*f_c);
c_value = num2str(c_value);
set(handles.cap_result,'string',c_value);
function plotbutton_Callback(hObject, eventdata, handles)
r_value1 = get(handles.r_values,'value');
switch r_value1
case 1
R = 1000;
case 2
R = 2000;
case 3
R = 3000;
case 4
R = 4000;
end
c_value1 = get(handles.cap_result,'string');
if get(handles.highbutton,'string') == 1
Gain = tf(R*c_value1,1 + R*c_value1);
bode(Gain)
elseif get(handles.lowbutton,'string') == 1
Gain = tf(1,1 + R*c_value1);
bode(Gain)
end

 採用された回答

Voss
Voss 2022 年 5 月 7 日
編集済み: Voss 2022 年 5 月 8 日

1 投票

If you have the Control System Toolbox or the System Identification Toolbox, you can try using bodeplot instead of bode, which will allow you to specify the (UI)Axes to plot into and other options.
References:
(They seem to be the same function in two different toolboxes, judging by their documentation pages.)

4 件のコメント

Badr Al-Sabri
Badr Al-Sabri 2022 年 5 月 7 日
編集済み: Badr Al-Sabri 2022 年 5 月 7 日
I tried this, but the function didn't plot anything
See the code so your vision can be complete, maybe the error is simple
Thanks for helping
Voss
Voss 2022 年 5 月 8 日
編集済み: Voss 2022 年 5 月 8 日
You should be getting the Value property of the radiobuttons, not the String property, in plotbutton_Callback:
if get(handles.highbutton,'Value') == 1
Gain = tf(R*c_value,1 + R*c_value);
axes(handles.axes1);
h = bodeplot(Gain);
elseif get(handles.lowbutton,'Value') == 1
Gain = tf(1,1 + R*c_value);
axes(handles.axes1);
h = bodeplot(Gain);
end
Badr Al-Sabri
Badr Al-Sabri 2022 年 5 月 8 日
Thanks Bro, this worked perfectly.
Voss
Voss 2022 年 5 月 8 日
Great! You're welcome!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB についてさらに検索

質問済み:

2022 年 5 月 7 日

コメント済み:

2022 年 5 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by