Find unknown from the equation with given values

I'm try to find the value of an unknown from an equation.
for simplicity sake,
values of a = [1;2;3;4]
a = b + 1
how do i find values of b for each values of a?
thank you so much in advance

Answers (1)

b=a-1;
WTP?
Since your real problem is apparently more complex than grade school mathematics, use solve.
syms a b
b = solve(a == b + 1,b)
b =
a - 1
b = double(subs(b,a,1:4))
b =
0 1 2 3
Or if you don't have the symbolic TB, use fzero, in a loop, solving for one element at a time.

1 Comment

yeah, the real equation is quite long. thanks, i will try your solution.

Sign in to comment.

Products

Community Treasure Hunt

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

Start Hunting!