声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 890|回复: 3

请求高手看下哪错了怎么改

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

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

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

x
有人会改这个程序不~!<BR>&gt;&gt; function [xp,yp,t,d]=calculate_distance(b,X,Y)<BR>% Calculate distance between bezier curve and a point<BR>%  [xp,yp,t,d]=calculate_distance(b,X,Y)<BR>if ~strcmpi(class(b),'bezier')<BR>  error('Expecting a bezier object');<BR>end<BR>[x0,ax,bx,cx,y0,ay,by,cy]=deal(b.x0,b.ax,b.bx,b.cx,b.y0,b.ay,b.by,b.cy);<BR>jj=[ay^2+ax^2,2*(by*ay+bx*ax),2*cy*ay+by^2+2*cx*ax+bx^2,...<BR> 2*(-X+x0)*ax+2*cx*bx+2*(-Y+y0)*ay+2*cy*by,...<BR> 2*(-Y+y0)*by+cy^2+2*(-X+x0)*bx+cx^2,...<BR> 2*(-Y*cy+y0*cy-X*cx+x0*cx),(-Y+y0)^2+(-X+x0)^2];<BR>dj=polyder(jj);<BR>r=roots(dj);<BR>i=find(imag(r)==0 &amp; r&gt;=0 &amp; r&lt;=1);<BR>pt=[0,1];<BR>if ~isempty(i)<BR>  pt=[pt,r(i)'];<BR>end<BR>v=polyval(jj,pt);<BR>[m,i]=min(v);<BR>t=pt(i);<BR>xp=polyval([ax bx cx x0],t);<BR>yp=polyval([ay by cy y0],t);<BR>d=norm([xp yp]-[X Y]);<BR><BR>??? function [xp,yp,t,d]=calculate_distance(b,X,Y)<BR>    |<BR>Error: Function definitions are not permitted at the prompt or in scripts.<BR>后边两行提示的错误~<BR>
回复
分享到:

使用道具 举报

 楼主| 发表于 2006-6-11 15:00 | 显示全部楼层

还有这个~

<P>&gt;&gt; % bezier_demo<BR>disp('Enter 4 points to define a Bezier curve and than edit it in WYSYWIG.');<BR>disp('You can move both end points and control points. Close the window when you are ready.');<BR>p=ginput(4);<BR>c=num2cell(p(:)');<BR>delete(gcf);<BR>[x0,y0,x1,y1,x2,y2,x3,y3]=deal(c{:});<BR>b=bezier('xpoints',[x0,y0,x1,y1,x2,y2,x3,y3]);<BR>c=edit_curve(b)<BR>hold on<BR>disp('Now variable c contains a Bezier object.');<BR>Enter 4 points to define a Bezier curve and than edit it in WYSYWIG.<BR>You can move both end points and control points. Close the window when you are ready.</P>
<P>??? Undefined command/function 'bezier'.<BR></P>
发表于 2006-6-11 19:53 | 显示全部楼层

回复:(swswkr123)请求高手看下哪错了怎么改

你都没有定义bezier这个函数
发表于 2006-6-12 12:05 | 显示全部楼层
你的东西是个子程序吧,先建立m文件才能在命令窗口运行吧
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-9-23 17:20 , Processed in 0.061666 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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