Make an implicit function in matlab?

I need matlab to create a function for me. I have,
y=e*h*sqrt(4ah+(1-e)*a*h)+(1-e*h)*sqrt((1-e)*2*h) in the interval 0<=e<=1 and 0<=h<=1.
I need a function of max y as a function of h (i.e. e is implicit). How can can matlab create this?
Thanks!

Antworten (1)

Torsten
Torsten am 15 Mai 2017

1 Stimme

Use "fminbnd" to search for the minimum of the function
f=@(x)-(x*h*sqrt(4a*h+(1-x)*a*h)+(1-x*h)*sqrt((1-x)*2*h))
in the interval [0:1]
Best wishes
Torsten.

4 Kommentare

David Sjöberg
David Sjöberg am 15 Mai 2017
Bearbeitet: David Sjöberg am 15 Mai 2017
Thanks!
However I get the error "Conversion to logical from sym is not possible.". I use the code:
syms h x
f = @(x)-(x*h*sqrt(4*h+(1-x)*2*h)+(1-x*h)*sqrt((1-x)*2*h))
k = fminbnd(f, 0, 1)
Am i using your answer correctly? :)
Torsten
Torsten am 15 Mai 2017
Bearbeitet: Torsten am 15 Mai 2017
f = @(x,h)-(x*h.*sqrt(4*h+(1-x)*2*h)+(1-x*h).*sqrt((1-x)*2*h));
n = 30;
h_array = linspace(0,1,n);
for i = 1:n
h = h_array(i);
k(i) = fminbnd(@(x)f(x,h), 0, 1);
end
plot(h_array,k)
Best wishes
Torsten.
David Sjöberg
David Sjöberg am 15 Mai 2017
Thanks again. I get "undefined variable h". But I still get the same error of conversion if I define h as a variable. Sorry for being slow to understand.
Torsten
Torsten am 15 Mai 2017
I modified the code from above.
Best wishes
Torsten.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Programming finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 15 Mai 2017

Bearbeitet:

am 15 Mai 2017

Community Treasure Hunt

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

Start Hunting!

Translated by