How do I solve this equation for x given a value of z and y?

z = (10.^(-15).*x.^(3).*exp((x.^2).^(-1)/4).*y.^(-1)).^(1/5)
Is there a way to numerically solve this equation for x given specific values of z and y? I am having trouble imputing the syntax and getting it to run correctly.

 Accepted Answer

Re-write the equation as:
f = @(x)(10.^(-15).*x.^(3).*exp((x.^2).^(-1)/4).*y.^(-1)).^(1/5)-z
Then let FZERO have a crack at it. Note that y and z should be defined before creating that function handle. For example:
z = 0.05;
y = 1/20;
f = @(x) (10.^(-15).*x.^(3).*exp((x.^2).^(-1)/4).*y.^(-1)).^(1/5)-z;
fzero(f,1)

7 Comments

Awesome this did the trick thanks! I was wondering though if its possible to assign a range of values for z and y in order to obtain plots from this?
You will have to loop them, as FZERO expects the function to return a scalar.
All right, also the other equation that is similar that I need to solve in the same fashion:
z = 0.05;
y = 0.05;
f = @(x) (10.^(-10).*x.^(2).*exp((x.^2).^(-1)/4).*y.^(-1)/2).^(1/4)-z;
fzero(f,1);
I used your recommended syntax but when I I run it it simply doesn't give an answer. It doesn't give an error either it's strange, it's as if nothing happened, I appreciate your help very much.
You have a semicolon on the end of the call to FZERO. If you want to see the answer, either take the semicolon off or assign get the return arg and display that. Example using the parameters copied and pasted from your last comment.
>> rt = fzero(f,1); % Now use rt for further processing...
>> rt % Display what is in rt...
rt =
0.14049
[(1/2)/(-LambertW(-1, -1/25000))^(1/2), (1/2)/(-LambertW(-1/25000))^(1/2)]
which is [.1404942646, 79.05536030]
I used to do that one all the time! ;)

Sign in to comment.

More Answers (0)

Categories

Find more on Function Creation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!