MATLAB: Hello i am asking about how to solve this error? ..Note that input : q=[0.1,0.2,0.3,0.4,0.5] and z=[0,1,2,3,4]

poisson

function y=c(q,z)
p=1-q;
lambda=z.*q./p;
sum=1;
for k=0:max(z)
poisson=exp(-lambda);
for i=1:k
poisson=poisson.*lambda./i;
end
sum=sum-poisson.*(1-((q/p).^(z-k)));
end
y=array2table(sum);
end

Best Answer

You are asking to do element by element multiplication of a 5 x 1 vector and a 1 x 5 vector. For the .* operator, the array sizes must be the same or one of them needs to be a scalar, unless you are using R2016b or later (which we can deduce you are not using)