Trying to input values into function with previously symbolically defined variables and plot the function, but getting error

I wanted MATLAB to simplify T_h symbolically, and then wanted to graph T_h using the specific values of Ra, Rb, and Ca that you see below. For some reason, I keep getting the error "Conversion to double from sym is not possible." Any ideas? Thank you in advance!
clc; clear; close all;
syms w Rah Rbh Cah
%Simplifying High-Pass Gain Found
T_h = sqrt(((-Rah*Rbh.*(Cah.*w).^2)/((Rah.*w.*Cah).^2 +1)).^2 + ((-Rbh.*w.*Cah)/((Rah.*w.*Cah).^2+1)).^2);
pretty(T_h)
T_hs = simplify(T_h);
pretty(T_hs)
%Plotting High-Pass Gain vs Angular Frequency
w = 0:0.01:10000;
Rah_v = 10;
Rbh_v = 10;
Cah_v = 0.05;
T_hs_v = subs(T_hs,[Rah,Rbh,Cah],[Rah_v,Rbh_v,Cah_v])
figure
subplot(2,1,1)
semilogx(w,T_hs_v)
hold on

Answers (1)

David, try
...
%Plotting High-Pass Gain vs Angular Frequency
ww = logspace(1,5,100);
Rah_v = 10;
Rbh_v = 10;
Cah_v = 0.05;
T_hs_v = subs(T_hs,[Rah,Rbh,Cah],[Rah_v,Rbh_v,Cah_v]);
T_hs_v = subs(T_hs_v,'w',ww);
figure
subplot(2,1,1)
semilogx(ww,T_hs_v)
hold on
I recommend defining a new variable ww that contains numeric values versus the symbolic variable w. Also, if you're planning to use a log plot it makes sense to assign values accordingly, e.g., using logspace.

This question is closed.

Asked:

on 9 Mar 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!