yuqing 发表于 2006-5-12 11:58

请教,可以获得ezplot运算过程中的数据吗?

如题,或者还有别的方法可以获得隐函数对应的数据吗?多谢各位大侠指点



[ 本帖最后由 xinyuxf 于 2007-7-23 15:39 编辑 ]

yuqing 发表于 2006-5-13 17:52

为什么没有人回答吗?是问题太弱智了还是没有人研究过这个问题啊?<BR>请各位帮忙考虑一下,我真的很着急知道,要不就前功尽弃了<BR><BR>小女子再次谢过

happy 发表于 2006-5-13 18:00

回复:(yuqing)请教,可以获得ezplot运算过程中的数...

<PRE>function implot(fun,rangexy,ngrid)<BR>% Implicit plot function<BR>% function implot(fun,rangexy,ngrid)<BR>% fun is 'inline' function f(x,y)=0 (Note function written as equal to zero)<BR>% rangexy = range over which x and y is ploted default(-2*pi,2*pi)<BR>% ngrid is the number of grid points used to calculate the plot,<BR>% Start with course grid (ngrid =20) and then use finer grid if necessary<BR>% default ngrid=50<BR>%<BR>% Example <BR>% Plot y^3+exp(y)-tanh(x)=0<BR>%<BR>% write function f as an 'inline' function of x and y-- right hand side <BR>% equal to zero<BR>%<BR>% f=inline('y^3+exp(y)-tanh(x)','x','y')<BR>% implot(f,[-3 3 -2 1])<BR><BR><BR>%       A.Jutan UWO 2-2-98ajutan@julian.uwo.ca<BR><BR><BR><BR>if nargin == 1;% grid value and ranges not specified calculate default<BR>      rangexy=[-2*pi,2*pi,-2*pi,2*pi];<BR>   ngrid=50;<BR>end<BR><BR><BR>if nargin == 2;% grid value not specified<BR>   ngrid=50;<BR>end<BR><BR><BR>% get 2-D grid for x and y<BR><BR><BR>xm=linspace(rangexy(1),rangexy(2),ngrid);<BR>ym=linspace(rangexy(3),rangexy(4),ngrid);<BR>=meshgrid(xm,ym);<BR>fvector=vectorize(fun);% vectorize the inline function to handle vectors of x y<BR>fvalues=feval(fvector,x,y); %calculate with feval-this works if fvector is an m file too<BR>%fvalues=fvector(x,y); % can also calculate directly from the vectorized inline function<BR>contour(x,y,fvalues,,'b-');% plot single contour at f(x,y)=0, blue lines<BR>xlabel('x');ylabel('y');<BR>grid<BR></PRE><BR><BR>用这个函数吧

yuqing 发表于 2006-5-13 22:31

回复:(happy)回复:(yuqing)请教,可以获得ezplo...

我仔细阅读了这个程序,我的目的是想获得f(x,y)=0上的点的数据,即隐函数图像上的点的数据,可是上述程序是通过画等高线得到的图像,我如何通过这个图像得到我想要得坐标呢?或者还有别的方法可以得到f(x,y)=0上的点的数据吗?<BR>谢谢

tigerlun 发表于 2008-6-17 22:13

请问楼主,这个问题解决了吗?我好想知道。

yeyunxiaopan 发表于 2009-9-19 12:49

h=ezplot('x+y=0,[-2,2]);
x1=get(h(1),'XData');
y1=get(h(1),'YData');

heizaoniangao 发表于 2009-9-19 18:59

回复 地板 yuqing 的帖子

contour(x,y,fvalues,,'b-');% plot single contour at f(x,y)=0, blue lines
把这一行变成=contour(x,y,fvalues,,'b-');
c就是你要找的东西
h是句柄
help contour

heizaoniangao 发表于 2009-9-19 19:03

回复 楼主 yuqing 的帖子

6楼的方法更简单,不过不用h(1)吧,用h就行了,ezplot里的函数少了一个“'”,小瑕疵,嘿嘿
页: [1]
查看完整版本: 请教,可以获得ezplot运算过程中的数据吗?