2012-07-24 79 views
0

我想在该地区0 < p < 1, 0 < q < 1-p绘制表格情节与约束MATLAB中的变量

f(p,q)=0

的功能。我用ezplot

ezplot('f(p,q)',[0,1]) 

是我能做的。但它看起来很丑,因为这个函数只在三角形区域0 < p < 1, 0 < q < 1-p中有很好的定义。因此,除了这个区域,我认为它只是绘制了函数的真实/虚构部分,因此也是丑陋的。但我想只画在三角形区域0 < p < 1, 0 < q < 1-p

有人可以帮忙吗?

回答

0

下面是一个如何去拉出想要绘制的值的例子。尽管如此,这绝不是复制粘贴的答案。

p = -1:.1:2; % Just giving p some random values so that we can pull 0 < p < 1 from it. 
ind = intersect(find(p>0), find(p<1)); % This returns the intersection of the two sets from p. Not really the best way, but it's a concise one-liner. 

% Now to pull the values from p. 
p_values = p(ind); % That simple! This is because ind has the actual indexes where p < 1 and p > 0. 

老实说这可能不是走出p的信息的最佳方式,但它只是什么来把我的头顶部之前,我让我的咖啡去。

至于拉q的信息,你可以按照类似的方式,只要确保你保持在你设定的约束范围内。

记住,当谈到绘制你需要有相同长度的载体,但如果你索引的p_values为了让你q_values你应该很好。

希望能让你有所启发,走上正确的道路。

+0

函数我有f(p,q)= 0不能很容易解决q。所以,找到q_values会非常困难。我从来没有想过这个问题很难。 – Ashok 2012-07-24 14:12:20

+0

这可能有助于张贴实际的功能/代码,以便人们可以看看实际数据是什么样的,并且可以提供更多的帮助。 – 2012-07-24 14:23:34