rocwoods:
>> clear all
kk=linspace(0,5);
y=zeros(size(kk));
ff=@(k) ['sin(',num2str(k),'*x).*x.^2'];
f=@(k) quadl(ff(k),1,5);
for ii=1:length(kk)
y(ii)=f(kk(ii));
end
plot(kk,y)
??? ff=@(k) ['sin(',num2str(k),'*x).*x.^2'];
|
Error: "identifier" expected, "(" found.
那个不用循环的代码:
>> plot(linspace(0,5),arrayfun(@(k) quad(@(x) sin(k.*x).*x.^2,0,5),linspace(0,5)))
??? plot(linspace(0,5),arrayfun(@(k) quad(@(x) sin(k.*x).*x.^2,0,5),linspace(0,5)))
|
Error: "identifier" expected, "(" found.
兄能否做下解释?
我用的是matlab6.5 |