# MATLAB: Vector output from a for loop

for loophelpif statementvector

Hello everyone,
I have an hourly temperature data which covers 8760 values inside a vector. The TMP shows the temperature values however the values below in the code is just for example since i can't put 8760 values here.
I want to get PGRED results as a vector output too. However, when i run the code, although it calculates PGRED values for all TMP values, i get an answer only for the last TMP value which is 36 in this case. My question is, how can i get all the PGRED answers inside 1 vector.
for TMP =[12, 3, 36]             if TMP < 9     PGRED=0   elseif 9<=TMP & TMP<10    PGRED= TMP-9    elseif 10<=TMP & TMP<28    PGRED= 1    elseif 28<=TMP & TMP<40    PGRED= -0.083*TMP + 3.33   else 40 >= TMP    PGRED=0      end   end
TMP =[12, 3, 36];PGRED=zeros(size(TMP));for ii=1:length(TMP)             if TMP(ii) < 9     PGRED(ii)=0;   elseif 9<=TMP(ii) && TMP(ii)<10    PGRED(ii)= TMP(ii)-9;    elseif 10<=TMP(ii) && TMP(ii)<28    PGRED(ii)= 1;    elseif 28<=TMP(ii) && TMP(ii)<40    PGRED(ii)= -0.083*TMP(ii) + 3.33;   else %40 >= TMP(ii) % this condition is not required. Just give a default condition.    PGRED(ii)=0;      end   end