|
楼主 |
发表于 2011-4-19 03:42
|
显示全部楼层
各位辛苦回帖,我做下整理工作。
qibbxxt 的离散方法
- 1. n = 3;
- 2. x = linspace(0,pi);
- 3. y = tan(sin(x)) - sin(tan(x));
- 4. subplot(211)
- 5. plot(x,y);
- 6. x1 = bsxfun(@plus,repmat(x',1,3),(0:n-1)*pi);
- 7. y1 = repmat(y,1,n);
- 8. subplot(212)
- 9. plot(x1(:),y1)
复制代码 meiyongyuandeze 离散方法
- 1. clc
- 2. clear
- 3. n = 3;
- 4. x1 = linspace(-1,1);
- 5. y = x1.^2;
- 6. subplot(211)
- 7. plot(x1,y);
- 8. x2=x1'*ones(1,n)+ones(length(x1),1)*[0:2:2*(n-1)];
- 9. y1=y'*ones(1,n);
- 10. subplot(212)
- 11. plot(x2,y1)
复制代码 321forever
for循环连续
- 1. function y=qq(x)
- 2. y=x^2.*(x>=-1&x<1);
- 3. for i=1:2
- 4. y=y+(x-2*i)^2.*(x>=-1+2*i & x<1+2*i);
- 5. if i==2
- 6. y=y+1.*(x==5);
- 7. end
- 8. end
- 9. y=@qq;
- 10. fplot(y,[-1,5])
复制代码
qibbxxt 的连续方法
- 1. f = @(x)x.^2.*(x>=-1 & x<1);
- 2. g = @(x,i)f(x-i);
- 3. x = linspace(-1,5,500);
- 4. y = arrayfun(@(i)g(x,i),0:2:4,'Uni',0);
- 5. plot(x,sum(cell2mat(y')))
复制代码
|
|