用function写了一个函数,希望能够输出两个不同的数组,如[a,b]=fun(x),其中a,b为两个不同的数组,但是貌似b会将a的结果覆盖,得到的ans只有一个数组。程序如下:
function [thta,y]=Sa(N)
if N>=10000;
error('input must smaller than 10000')
end
tht=0:pi/9999:pi;
d=floor(10000/N);
y=[];
thta=[];
for i=0:N-1;
a=1+i*d;
thta=[thta,tht(a)];
y=[y,(sin((N/2)*pi*(cos(tht)-cos(thta(i+1)))))/(N*sin((pi/2)*(cos(tht)-cos(thta(i+1)))))];
end
end