How to a complex plot of three different variables ?

3 views (last 30 days)
Hi all,
I have this function,
k=[0.5 0.8];
F(x,y,z,k)=0.1*x*y+(k^2)*sqrt((1/x*y)^2+(2/z)^2)+3*z*y);
I am trying to plot this function in terms of three parameters for 2 values of k, k=0.5, 0.8; my ultimate goal is to find the optimal values for x,y and z for minimum F,
any help and hint in this?

Answers (2)

Walter Roberson
Walter Roberson on 16 Oct 2016
Vectorize the code on the right side. Put it into an anonymous function of three four variables. Now create an anonymous function
Fv1 = @(x) F(x(1),x(2),x(3), k(1))
now you can
X0 = rand(1,3);
[x1,f1] = fminsearch(Fv1, X0)
and construct similar for k(2). Compare f1 and f2 to determine which k value leads to a better optimized value. Use x1 or x2 for the x, y, z values.
  1 Comment
AbuYusuf
AbuYusuf on 16 Oct 2016
Edited: AbuYusuf on 16 Oct 2016
Thanks Walton for your input,
when I use the fminsearch, I always got an error; this is what I use,
k=0.8; x0=0;
fv=@(x)(0.1*x(3)*x(2)+4*x(1)*x(2)+(k^2)*sqrt((1/(x(2)*x(3)))^2+(0.65/x(1))^2));
[x,fval] = fminsearch(fv,x0);
I changed the initial condition x0 to 1e-6 but still I am getting the same error, I am not sure which x0 shoud I pick, but diffentaly they are bigger than zero for all and different ranges, ex. x(1) in micro range, x(2) in pico range and x(3) in Mega range.
I am expecting results like; x(1)=1e-6, x(2)=1e-12; x(3)=1e6; Is there a clue how can i choose the right x0?

Sign in to comment.


Image Analyst
Image Analyst on 16 Oct 2016
What is the value of z? If it's variable, then how do you expect to "plot" a function of 3 continuous variables? That would be like you're trying to model the temperature distribution in a solid at every single (x,y,z) point in the solid. You can't "plot" that. You'd have to do volume visualization of the solid volume, like isosurfaces or cutaway views. Or else you could do it for a few discrete values of z and use plot3().

Categories

Find more on App Building 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!