I have the following code which identifies the velocity values at different values of KK
.
load('Vq.mat')
KK=1;
ft = fftshift(fft2(Vq));
kx = [-70:1:70];
ky = [-70:1:70];
for i1=1:length(kx)
for i2=1:length(ky)
kh(i1,i2)=sqrt(kx(i1).^2 ky(i2).^2);
if (kh(i1,i2)>KK && kh(i1,i2)<KK 1)
else
ft(i1,i2)=0;
end
end
end
K=sum(ft);
So, when I set the value of KK
as 1 the code will then loop through the matrix kh
and find the locations where KK = 1
and grab the velocity at that location (through the if statement). The code then zeros all the other values in the ft
matrix and only keeps the velocity values at KK = 1
. I then sum these values to create K
.
My problem is that I want to loop through KK
values from 1:70
.
So when KK = 2
, the code would again loop through kh
and identify the velocities at KK = 2
. It would then sum these values and then add to the matrix K
.
At the end the single matrix of K should include all the sums of the individual values found at different values of KK