Reputation: 18586
for theta=1:10
x_3 = cos(theta);
syms x;
x_2 = 'x_3 - cos(x+theta)';
a = solve(x_2,x)
end
When I run this code, the solutions for a
include x_3
and theta
instead of substituting them with the values defined above. How can I solve this using the actual values of x_3
and theta
?
Upvotes: 0
Views: 293
Reputation: 5251
It is a problem of mixing syms
and strings?
Try:
syms x;
for theta = 1:10
x_3 = cos(theta);
x_2 = x_3 - cos(x+theta);
a = solve(x_2,x)
end
or
for theta = 1:10
x_3 = cos(theta);
x_2 = 'x_3 - cos(x+theta)';
a = solve(x_2,'x')
end
Upvotes: 1