MATLAB: How to output a vector instead of a scalar

outputvector

Hi,
I want to output x as a vector, but it only return a scalar,how should I do to fix this? Appreciate any response.
function [ x ]=problem1(b,c,d,f)
n=size(d,2);
e=zeros(n,1);
x=zeros(n,1);
e(1)=d(1);
for i=2:n
e(i)=d(i)-c(i-1)*b(i-1)/e(i-1);
end
x(n)=f(n)/e(n);
for i=n-1:-1:1
x(i)=(f(i)-c(i)*x(i+1))/e(i);
end
end
Test script:
n=8;
b=randn(n-1,1);
c=randn(n-1,1);
d=randn(n,1);
f=randn(n,1 );
x=problem1(b,c,d,f);

Best Answer

Define n like this:
n=length(d);