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
댓글 수: 0
답변 (1개)
Mischa Kim
2014년 3월 9일
편집: Mischa Kim
2014년 3월 9일
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.
댓글 수: 0
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!