How to a complex plot of three different variables ?

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?

답변 (2개)

Walter Roberson
Walter Roberson 2016년 10월 16일
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

AbuYusuf
AbuYusuf 2016년 10월 16일
편집: AbuYusuf 2016년 10월 16일
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?

댓글을 달려면 로그인하십시오.

Image Analyst
Image Analyst 2016년 10월 16일

0 개 추천

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().

카테고리

도움말 센터File Exchange에서 App Building에 대해 자세히 알아보기

질문:

2016년 10월 16일

답변:

2016년 10월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by