MATLAB: How to choose k values

for loop

hi all,
I have an array of 365 values and I do some calculations with an index for k=1:365
However, I need to do some different calculations for some k (let's say k=7, k=9,k=11, k=12)
how can I select only these?
I imagine is something like that: for k=1:365
if k=7…..
else…
thanks

Best Answer

It is easiest to address them directly:
v = randn(1,365); % Create Data
k = 1:365; % Index Vector
select_k = [7 9 11 12]; % Select ‘k’ Values
select_v = v(select_k); % Select ‘v’ Values