Error using the solve command

5 views (last 30 days)
Joshua
Joshua on 11 Jun 2013
Hello, I'm currently using the solve command to try and solve a system of 2 equations with 2 unknowns.
The code I'm using looks like this:
syms h Tf;
s=solve('((Tw1(1)-Ti)/(Tf-Ti))=1-exp(((h^2)*alpha*t1)/(k^2))*erfc((h*sqrt(alpha*t1))/k), ((Tw2(1)-Ti)/Tf-Ti)=1-exp(((h^2)*alpha*t2)/(k^2))*erfc((h*sqrt(alpha*t2))/k)',h,Tf)
Tw1(1), Ti, alpha, t1, t2, and k are all known values in this.
It is returning an error message stating:
"Warning: Explicit solution could not be found.
> In solve at 81
In datareduction at 53
sol =
[ empty sym ]"
I know that there should be a solution to this system, as it has been proven before, I am just unable to figure out the proper way to solve it in MATLAB. Any help is greatly appreciated.
Thank you.
  2 Comments
Walter Roberson
Walter Roberson on 12 Jun 2013
What are Tw2(1) and Tw1(1) intended to be?
You have them appearing in quoted strings, so they will be interpreted according to MuPAD syntax instead of MATLAB syntax. In MuPAD, () is only used for function parameter, not for indexing. Tw2(1) inside a quoted string means the function Tw2, applied with the parameter 1. If you wanted Tw2 subscript 1, you would use Tw2[1] inside quoted strings.
Joshua
Joshua on 12 Jun 2013
Tw2(1) and Tw1(1) are values from two separate 1x3072 matrices. I see what your saying now. I want Tw2[1] because I'm referencing a value.

Sign in to comment.

Answers (1)

Alan Weiss
Alan Weiss on 11 Jun 2013
Edited: Alan Weiss on 11 Jun 2013
You cannot really expect a symbolic solution to such a problem involving, as it does, the complementary error function. Instead, you can try a numeric solution for given values of your other parameters by using the fsolve function.
In MuPAD, you can use the numeric::fsolve function.
Good luck,
Alan Weiss
MATLAB mathematical toolbox documentation
  6 Comments
Walter Roberson
Walter Roberson on 12 Jun 2013
The representation of Tf in terms of h is rather messy: it involves finding the roots of a non-polynomial expression, one of terms of which involves a value which is the root of another non-polynomial expression. With a structure like that, accuracy would tend to be a big problem: the default MuPAD 10 digits of calculation is likely not going to be enough.
Roger Stafford
Roger Stafford on 12 Jun 2013
I disagree Walter. There is no polynomial involved. The first equation has this form:
k1/(Tf-k2) = 1-exp((k3*h)^2)*erfc(k3*h)
where I have combined some of the parameters into k1, k2, and k3. It is readily solved for Tf in terms of h:
Tf = k2 + k1/(1-exp((k3*h)^2)*erfc(k3*h))
Combined with a similar expression derived from the second equation this will give a single equation in a single unknown, h. However I doubt if there exists an explicit solution to this single equation, and hence it must be solved numerically, presumably with 'fzero', for each different set of given parameters.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!