声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 2239|回复: 7

[编程技巧] 请教,可以获得ezplot运算过程中的数据吗?

[复制链接]
发表于 2006-5-12 11:58 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

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



[ 本帖最后由 xinyuxf 于 2007-7-23 15:39 编辑 ]
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-5-13 17:52 | 显示全部楼层
为什么没有人回答吗?是问题太弱智了还是没有人研究过这个问题啊?<BR>请各位帮忙考虑一下,我真的很着急知道,要不就前功尽弃了<BR><BR>小女子再次谢过
发表于 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 =[xmin,xmax,ymin,ymax] 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-98  ajutan@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>[x,y]=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,[0,0],'b-');% plot single contour at f(x,y)=0, blue lines<BR>xlabel('x');ylabel('y');<BR>grid<BR></PRE><BR><BR>用这个函数吧
 楼主| 发表于 2006-5-13 22:31 | 显示全部楼层

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

我仔细阅读了这个程序,我的目的是想获得f(x,y)=0上的点的数据,即隐函数图像上的点的数据,可是上述程序是通过画等高线得到的图像,我如何通过这个图像得到我想要得坐标呢?或者还有别的方法可以得到f(x,y)=0上的点的数据吗?<BR>谢谢
发表于 2008-6-17 22:13 | 显示全部楼层
请问楼主,这个问题解决了吗?我好想知道。
发表于 2009-9-19 12:49 | 显示全部楼层
h=ezplot('x+y=0,[-2,2]);
x1=get(h(1),'XData');
y1=get(h(1),'YData');
发表于 2009-9-19 18:59 | 显示全部楼层

回复 地板 yuqing 的帖子

contour(x,y,fvalues,[0,0],'b-');% plot single contour at f(x,y)=0, blue lines
把这一行变成[c,h]=contour(x,y,fvalues,[0,0],'b-');
c就是你要找的东西
h是句柄
help contour
发表于 2009-9-19 19:03 | 显示全部楼层

回复 楼主 yuqing 的帖子

6楼的方法更简单,不过不用h(1)吧,用h就行了,ezplot里的函数少了一个“'”,小瑕疵,嘿嘿

评分

1

查看全部评分

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-16 05:45 , Processed in 0.119491 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表