0

I used the following matlab code to solve a system of algebraic equations, but I got no answer.

clear; clc; close all;

syms x y z u

eqns = [2x + 1 == 2ux, 4y == 2uy, 6z == 2u*z, x^2 + y^2 +z^2 == 1];

S = solve(eqns,[x y z u]);

S.u

the result says:

ans =

Empty sym: 0-by-1

But there should be answers, to see the answers, please refer to an MIT calculus course: https://www.youtube.com/watch?v=nDuS5uQ7-lo&list=PLkcAPvx7T8bBOOuDcxZE_sdTchjQcTyM-&index=29

So , what is wrong?

  • Try solve(2*x+1==2*u*x, 4*y==2*u*y, 6*z==2*u*z, x^2+y^2+z^2==1) instead – David Aug 13 '20 at 01:23
  • That works! ${}{}{}{}{}{}$ – mjw Aug 13 '20 at 01:27
  • Actually the problem was your eqns in the fourth equation x^2 + y^2 +z^2 ==1 gets interpreted by Matlab as two different elements, x^2 + y^2 and z^2==1. It needs a space before z^2 : x^2 + y^2 + z^2 ==1 – David Aug 13 '20 at 01:28
  • Thank you! @David It works! And as you said, the space caused the problem, that is really subtle. – Mike Mathcook Aug 13 '20 at 01:36

0 Answers0