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_3
和theta
,而不是使用上面定义的值替换它们。如何使用x_3
和theta
?
答案 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