Solving a formula in Matlab
1 view (last 30 days)
Belal Abboushi on 6 Mar 2015
In the following formula : X= 2y + 10 log(1+ E/S)
I want the user to input X, y, and S. Is there anyway i can get matlab to give me the value of E without having to rewrite the formula?
Thank you so much!
Giorgos Papakonstantinou on 6 Mar 2015
Edited: Giorgos Papakonstantinou on 6 Mar 2015
x = input('Enter the value of x: '); % request user input
y = input('Enter the value of y: ');
S = input('Enter the value of S: ');
f = @(E) 2.*y + 10*log(1+ E./S) - x; % create an anonymous function
[Eval, fval]= fsolve(f, 1); % solve your equation
or you can also:
f = 2.*y + 10*log(1+ E./S) == x;
If log refers to the base of 10 rewrite f by replacing log with log10.