Jethro
Jethro

Reputation: 13

(Matlab) Symbolic Toolbox: (Empty Sym) error in function file

I have had the opportunity to obtain the following code as answer to my earlier question.

function [] = calc_third(varname_1, var_value_1, varname_2, var_value_2)

    gamma = sym('gamma');
    M1 = sym('M1');
    TR = sym('TR');

    eq = TR ==(((gamma - 1)*M1^2 + 2)*(2*gamma*M1^2 - gamma + 1))/(M1^2*(gamma + 1)^2);

    subs_eq = (subs(eq,[sym(varname_1), sym(varname_2)],[var_value_1,var_value_2]));

    missing_var = symvar(subs_eq)

    solve(subs_eq,missing_var)

end

It is supposed to give an output below in console:

>>calc_third('gamma', 0.5, 'TR', 100)

missing_var =

M1

ans =

(2*2^(1/2))/(3*88609^(1/2) + 893)^(1/2)

Instead, Matlab gives me the following error:

>> calc_third('gamma',1.4,'TR',100)

missing_var = 

   Empty cell array: 0-by-1

Warning: List of equations is empty. 
> In solve at 70
  In calc_third at 13

ans =

[ empty sym ]

I am on Matlab 7.12.0 (R2011a), with symbolic toolbox.Have I miss anything out?

Upvotes: 0

Views: 802

Answers (1)

Jethro
Jethro

Reputation: 13

From the comments from other users, looks like symvar cannot identify the remaining variables in R2011a. This is not an issue for newer Matlab, at least from R2013a, with symbolic math toolbox v5.10 onwards.

Upvotes: 0

Related Questions