| 查看: 515 | 回复: 2 | ||
塞纳河的左岸金虫 (著名写手)
|
[求助]
matlab程序有误,望不吝赐教,十分感谢,matlab真的是零基础
|
|
用三次样条函数 去模拟汽车门的曲线,车门曲线的型值点数据如下 0 1 2 3 4 5 6 7 8 9 10 2.51 3.30 4.04 4.70 5.22 5.54 5.78 5.40 5.57 5.70 5.80 >> x=0:1:10; y=[2.51 3.30 4.04 4.70 5.22 5.54 5.78 5.40 5.57 5.70 5.80]; dy0=0.8; dy10=0.2; xx=0:.01:10; hh=h(x); uu=u(hh); dd=d(hh,y); d0=6.0/hh(1)*((y(2)-y(1))/hh(1)-dy0); d10=6.0/hh(10)*(dy10-(y(11)-y(10))/hh(10)); a=[uu 1]; b=[2 2 2 2 2 2 2 2 2 2 2]; c=[1 1-uu]; d=[d0 dd d10]; f1=m(a,b,c,d,x); for i=1:1001 yy(i)=s(x,y,hh,f1,xx(i)); end plot(x,y,'bo-',xx,yy,'r') ??? Undefined function or method 'h' for input arguments of type 'double'. >> function hh=h(x) n=length(x)-1; for i=1:n hh(i)=x(i+1)-x(i); end ??? function hh=h(x) | Error: Function definitions are not permitted in this context. >> function uu=u(x) n=length(x)-1; for i=1:n uu(i)=x(i)/(x(i)+x(i+1)); end ??? function uu=u(x) | Error: Function definitions are not permitted in this context. >> function dd=d(hh,y) n=length(hh)-1; for i=1:n dd(i)=6.0/(hh(i)+hh(i+1))*((y(i+2)-y(i+1))/hh(i+1)-(y(i+1)-y(i))/hh(i)); end ??? function dd=d(hh,y) | Error: Function definitions are not permitted in this context. >> function f=m(a,b,c,d,x) n=length(x)-1; for i=2:n r=a(i-1)/b(i-1); b(i)=b(i)-r*c(i-1); d(i)=d(i)-r*d(i-1); end d(n+1)=d(n+1)/b(n+1); for i=n:-1:1 d(i)=(d(i)-c(i)*d(i+1)/b(i+1))/b(i); end f=d; ??? function f=m(a,b,c,d,x) | Error: Function definitions are not permitted in this context. >> function an=s(x,y,h,f,x0) n=length(x)-1; for i=1:n if x0>=x(i)&x0<=x(i+1) an=f(i)*(x(i+1)-x0)^3/(6*h(i))+f(i+1)*(x0-x(i))^3/(6*h(i))+(y(i)-f(i)*h(i)^2/6)*(x(i+1)-x0)/h(i)+(y(i+1)-f(i+1)*h(i)^2/6)*(x0-x(i))/h(i); end end ??? function an=s(x,y,h,f,x0) | Error: Function definitions are not permitted in this context. 这个我真的不会,求指教啊 |
» 猜你喜欢
Cas 72-43-5需要30g,定制合成,能接单的留言
已经有8人回复
求助:我三月中下旬出站,青基依托单位怎么办?
已经有6人回复
北京211副教授,35岁,想重新出发,去国外做博后,怎么样?
已经有8人回复
磺酰氟产物,毕不了业了!
已经有5人回复
论文终于录用啦!满足毕业条件了
已经有25人回复
2026年机械制造与材料应用国际会议 (ICMMMA 2026)
已经有3人回复
自荐读博
已经有3人回复
不自信的我
已经有5人回复
投稿Elsevier的杂志(返修),总是在选择OA和subscription界面被踢皮球
已经有8人回复
» 本主题相关价值贴推荐,对您同样有帮助:
matlab优化求解中遇到问题,望大神指点。。。
已经有7人回复
matlab结果中,太小的数不用科学计数法,让其显示为零(四舍五入),怎么办?
已经有10人回复
用Matlab生成一张类似魔方的图片,望各路大神指教!!!!!!!!
已经有3人回复
高手进来用matlab求解常微分方程,十分感谢!
已经有17人回复


2楼2014-11-24 12:40:08
塞纳河的左岸
金虫 (著名写手)
- 应助: 4 (幼儿园)
- 金币: 2426.1
- 散金: 10
- 红花: 3
- 帖子: 1179
- 在线: 234.6小时
- 虫号: 1388927
- 注册: 2011-09-03
- 性别: GG
- 专业: 电化学

3楼2014-11-24 14:23:25









回复此楼