等式中的非符号变量

时间:2011-12-06 12:14:11

标签: matlab equation

for theta=1:10
  x_3 = cos(theta);

  syms x;
  x_2 = 'x_3 - cos(x+theta)';

  a = solve(x_2,x)
end

当我运行此代码时,a的解决方案包括x_3theta,而不是使用上面定义的值替换它们。如何使用x_3theta

的实际值来解决此问题

1 个答案:

答案 0 :(得分:1)

这是混合syms和字符串的问题吗?

尝试:

syms x;
for theta = 1:10
    x_3 = cos(theta);
    x_2 = x_3 - cos(x+theta);
    a = solve(x_2,x)
end

for theta = 1:10
    x_3 = cos(theta);
    x_2 = 'x_3 - cos(x+theta)';
    a = solve(x_2,'x')
end