MATLAB: Determinate values for symbolic variable

symbolic plot

Hi guys, I 'm working on a code that determines the equation for the RLC circuit accordin with variables entering. And i needed put t as a symbolic, but i want to plot graphics with some values of t, how i can do it? Here is the code (im working with the last case at least, after this, i am coming to others, and sorry for my bad english):
format bank
io= input('insira o valor da corrente inicial: ');
vo= input('insira o valor da tensão inicial: ');
R= input('insira o valor da resistência: ');
C=input('insira o valor da capacitãncia: ');
L= input('insira o valor da indutância: ');
alfa = R/(2*L);
omega= 1/(sqrt(L*C));
DiDt= -(R*io - vo)/L;
syms t A B
a= -alfa + sqrt(alfa^2 - omega^2);
b= -alfa - sqrt(alfa^2 - omega^2);
f = abs(alfa^2 - omega^2);
p= abs(sqrt(f));
a1=sym(a,'d');
b1=sym(b,'d');
p1=sym(p,'d');
%f1 = sym(f,'d');
tau = 1/p1;
if alfa > omega
fprintf('Trata-se de um amortecimento supercrítico, tendo como equação caracteristica é dada por:\n i(t) = ')
i1 = A*(exp(a1*t)) + B*(exp(b1*t));
pretty(i1)
%MATA = [1 1; a b];
%c = [io ; DiDt];
elseif alfa == omega
fprintf('Trata-se de um amortecimento crítico, tendo como equação caracteristica é dada por:\n i(t) = ')
i2 = (A +B*t)*exp(-alfa*t);
pretty(i2);
%MATB = [ 1 0 ; -alfa 1];
%d = [io ; DiDt];
else
fprintf('Trata-se de um subamortecido, tendo como equação caracteristica é dada por:\n i(t) = ')
%i3= exp(-alfa*t)*(A*cos(p1*t) + B*sin(p1*t));
MATC = [ 1 0 ; -alfa p1 ];
e = [io ; DiDt];
ValorConst = (MATC\e)';
i3 = exp(-alfa*t)*(ValorConst(1)*cos(p1*t) + ValorConst(2)*sin(p1*t));
pretty(i3)
fplot(i3, [0,10])
end

Best Answer

To plot a symbolic expression S in t, over the range A to B, use something like,
tvals = linspace(A,B); %create range of values
y = double( subs(S, t, tvals) );
plot(tvals, y)
Related Question