MATLAB: Problem with solve and syms variable

MATLABsolvesymbolic

Hi, I'm fairly new (and bad) with MATLAB script. I'm trying to build a program to compute MOSFET power losses on each commutation interval. So what I want to do is just input some constants and MATLAB solves the power losses for me and the time taken by each interval. This is where I have some problems. I am trying to use the function solve to solve a simple 1 equation and 1 variable system for the first interval. The code is the following:
if true
% %CONSTANTE DU CIRCUIT À DÉTERMINER
V_DR_m = 0; %Tension d'attaque minimale de la gate du MOSFET
V_DR_p = 15; %Tension d'attaque maximale de la gate du MOSFET
Rg = 5; %Résistance connectée à la gate du MOSFET
%



%CONSTANTE DU MOSFET À DÉTERMINER
Rg_FET = 5; %Résistance parasite de la gate de MOSFET
Cdg = 100*10^(-12); %Capacitance de Miller Drain-Gate du MOSFET
Cgs = 2000*10^(-12); %Capacitance de Miller Gate-Source du MOSFET
VT = 6; %Tension de mise en conduction du MOSFET (threshold)
%
%VARIABLES DU CIRCUIT
syms t %Temps
var vGS %Tension Gate-Source du MOSFET en fonction du temps
%
%--------------INTERVALLES DU TURN ON--------------
%INTERVALLE 1
%Mise à ON du gate driver. Intervalle se terminant lorsque
%la tension de gate atteint la tension de mise en conduction
%du MOSFET VT.
R_DR = Rg_FET+Rg;
tauG = R_DR*(Cdg+Cgs);
vGS = ((V_DR_m-V_DR_p)*exp(-t/tauG))+V_DR_p;
solt = solve(vGS == VT, t);
%
end
And when I run the program, not only there is nothing in all the variables defined as syms, but ans also gives the answer 596.3333 which I have no clue at all where it is from. The values of solt, t and vGS are all specified as 1×1 sym and when I click on them, there is nothing in what I suppose should be a 1×1 array containing my solve's answer. I haven't seen any code differences compared to some other simple solve function on the internet. Also the answer to t should be t=10.7273e-9. Also, ignore the french comments. They are only there to explain how the commutation intervals of the MOSFET work. Thank you very much in advance.

Best Answer

Hi,
use:
syms t
and
solt = double(solve(vGS == VT, t));
instead of:
syms t
var vGS
and
solt = solve(vGS == VT, t);
Then you get the desired result.
Regarding the 596.3333 result i am not sure what exactly happens, but in this context var is definetly not correct, since it is the variance function. If you want to declare vGS as a function of t, use:
syms vGS(t)
I guess that you wanted to do this.
Best regards
Stephan