About CVX summation problem

The Problem as follow, I think it is a convex optimization problem, Is it really a convex?

minimize ∑i=1 to M (Pi)^2, for example if M=3, (P1)^2+(P2)^2+(P3)^3, Pi is the variable which I want to optimize

3 Constraint:

  1. ∑i=1 to M Pi=1
  2. ∑i=1 to M PiaEi<=b , where a,b are constant, Ei are also array of constant
  3. 0<=Pi<=1, i=1,…M

My CVX coding as following:

a=0.0005;
b=5;
e={1,3,6,9,12};
x={0,0,0,0,0};
cvx_begin
    obj=0;
    sub=0;
    sub1=0;
    variable p(5,1)
    for i=1:5
        obj=obj+p(i)*p(i)
    end
    minimize (obj)
   x=p                     //Used to output the optimized Pi, such as P1, P2, P3, P4 ,P5 to matlab for further computation
    subject to 
     for i=1:5
        sub=sub+p(i)
    end
        sub==1
     for i=1:5
        sub1=sub1+p(i)*a*e(i)//error occur on e(i), which is a constant array value set in the matlab code outside cvx
     end
        sub1<=b
        0<=p
        p<=1
        
cvx_end

Is the above program obey the my problem requirement and constraint?
Please help me for that!! Noted with thanks!