24小时热门版块排行榜    

查看: 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.




这个我真的不会,求指教啊
回复此楼
最是那一低头的温柔,像一朵水莲花不胜凉风的娇羞~
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

时雨晨星

铁虫 (初入文坛)

现在还需要吗?
天生我材必有用
2楼2014-11-24 12:40:08
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

塞纳河的左岸

金虫 (著名写手)

引用回帖:
2楼: Originally posted by 时雨晨星 at 2014-11-24 12:40:08
现在还需要吗?

周二交作业,所以还希望您不吝赐教啊,我matlab零基础啊
最是那一低头的温柔,像一朵水莲花不胜凉风的娇羞~
3楼2014-11-24 14:23:25
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 塞纳河的左岸 的主题更新
信息提示
请填处理意见