Plot a function with respect to another function

9 次查看(过去 30 天)
Dear guys,
I have two functions, each function of two variables x,y; namely z1 = f1(x,y) and z2 = f2(x,y) and want to plot z1 vs z2. The functions are below:
0 <= x,y <= 1;
z1 = -(1-x) .* ( (y./(1-x)).*(log((y./(1-x)))) + (1-((y./(1-x)))).*(log(1-((y./(1-x))))) ) /log(2);
z2 = -(1-y) .* ( (x./(1-y)).*(log((x./(1-y)))) + (1-((x./(1-y)))).*(log(1-((x./(1-y))))) ) /log(2);

采纳的回答

Walter Roberson
Walter Roberson 2014-3-11
Assign values to x and y, do the calculations producing z1 and z2, then
plot(z1, z2)
  7 个评论
Saeid Hajizadeh
Saeid Hajizadeh 2014-3-12
编辑:Saeid Hajizadeh 2014-3-12
Thanks to all guys, I focused. The answer is right. My problem was that I used to put directly p1 and p2 into R12 and R21. The correct code is given below:
p1 = 0.01:0.001:0.49;
p2 = 0.01:0.001:0.49;
for i=1:1:481
for j=1:1:481
R12(i,j) = -(1-p1(i)) .* ( (p2(j)./(1-p1(i))).*(log((p2(j)./(1-p1(i))))) + (1-((p2(j)./(1-p1(i))))).*(log(1-((p2(j)./(1-p1(i)))))) ) /log(2);
R21(i,j) = -(1-p2(j)) .* ( (p1(i)./(1-p2(j))).*(log((p1(i)./(1-p2(j))))) + (1-((p1(i)./(1-p2(j))))).*(log(1-((p1(i)./(1-p2(j)))))) ) /log(2);
end
end
plot(R12,R21)
Now this is a large number of diagrams plotted simultaneously the envelope of which is the answer. I am trying to find a way to extract envelope here. If you have any idea, I appreciate having them (I am very basic in Matlab)
Walter Roberson
Walter Roberson 2014-3-12
Also if y = 0 then you multiply 0 by log(0) which is going to give you NaN.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by