## solve an equation using solve() produces an array instead of a unique value

### jojo (view profile)

on 17 Nov 2019 at 21:43
Latest activity Commented on by Star Strider

### Star Strider (view profile)

on 18 Nov 2019 at 2:58
Accepted Answer by Star Strider

### Star Strider (view profile)

d = 32*h + 200*(32*h - 8)*((4*h - 1)^2 - 1) - 16
I am trying to solve for h using "solve(d,h)" , however, I keep getting an array for of solutions!
[1/2
1/8 - (7*2^(1/2))/80
(7*2^(1/2))/80 + 1/8 ]
How could I obtain a unique value for h? The solution does not seem right. Is there a better function to be used ?
Thanks.

### Star Strider (view profile)

Answer by Star Strider

### Star Strider (view profile)

on 17 Nov 2019 at 22:05

The result is correct. There are three roots.
Plot it to see the result:
syms h
d = 32*h + 200*(32*h - 8)*((4*h - 1)^2 - 1) - 16;
ds = solve(d)
figure
fplot(d, [-0.1 0.6])
hold on
plot(ds, zeros(size(ds)), 'pg')
hold off
grid

Star Strider

### Star Strider (view profile)

on 18 Nov 2019 at 1:25
I do not understand.
The ‘x’ and ‘y’ values do not appear anywhere in anything you have posted.
jojo

### jojo (view profile)

on 18 Nov 2019 at 1:49
I did not post them initially. I was just explaining that 'h' is to be assigned to some x and y parameters that take singular values. Is there a way of writing x and y such that they can take both single digits and arrays size of h? like x(:,3) something like that. I am knew to matlab and I do not fully grasp array slicing and indexing yet. Thanks.
Star Strider

### Star Strider (view profile)

on 18 Nov 2019 at 2:58
I will need more details.
It depends on how you want to define ‘h’ and what you want to do.