Hello Bill,,
Yeah, I know where's the mistakes now. I didn't declare w(i) inside the loop. And I made some mistakes in typing. I should type z in limit3 and limit4 instead of x. So when I write the script like below
%rectangular model
for i=1:length(x);
w(i)=1;
if x(i)<=lim1...