MATLAB: Index exceeds matrix dimensions

index exceeds dimensionsindexingMATLAB

When I run the following code, matlab shows me an error that the index exceeds matrix dimensions. It seems like it has an easy solution, but I am still relatively new to matlab and coding in general.
Some background info if required, I'm trying to validate a thermal model and x2 is reduced temperature and yp is predicted thermal efficiency. p1 and p2 depict my thermal coefficients.
Hope you can help me out!
k1 -> constant
x2 -> 100x1 (double)
p1 = [0:0.1:10]; %100 elements
p2 = [0:0.001:1]; %1000 elements
for m=1:length(p1)
for n=1:length(p2)
yp(m,n) = ((k1.*p2(m,n))./(p1(m,n)+p2(m,n)))-((x2(m,n).*(p1(m,n).*p2(m,n)))./(p1(m,n)+p2(m,n)));
end
end

Best Answer

k1 = 30
x2= [1:100]'
p1 = linspace(0,10,100); %100 elements

p2 = linspace(0,1,100); %100 elements
P=p1+p2
PP = p1.*p2
yp = ((k1*p2)./(P))-((x2.*(PP))./(P))