clarification in for loop with intervals

11 次查看(过去 30 天)
Hi,
I am running the for loop with the intervals as shown below, here at the end of each sequence I need to save the average image for e.g.55 to 65, then that particular matrix needs to be cleared then continue with next seqeunce i.e. 125:1:145 and so on.. Is there a way to do this ???
for kk = [55:1:65 125:1:145 201:1:225]
% my code
end
  2 个评论
dpb
dpb 2021-1-20
What's in the loop?
May not need it; certainly not in that form...
Turbulence Analysis
for kk = [55:1:65 125:1:145 201:1:225]
if (kk>=1) && (kk<=9)
fname_strt = 'B0000' ;
elseif (kk>=10) && (kk<=99)
fname_strt='B000';
elseif (kk>=100) && (kk<=999)
fname_strt='B00';
elseif (kk>=1000) && (kk<=9999)
fname_strt='B0';
else
fname_strt='B';
end
fname_end = num2str(kk);
fname = strcat(fname_strt,fname_end,'.vc7');
II = loadvec(fname);
x=(II.x);
y=(II.y);
v = II.vx;
fu2=flipud(v);
t1 = 1;
skT = 1;
skx = 1;
sky = 1;
skT = 1;
lx1 = 1;
lx2 = 89;
ly1 = 1;
ly2 = 97;
fu2 = medfilt2(fu2,[M M]);
U(:,:,((kk-t1+1)-1)/skT+1) = fu2(lx1:skx:lx2,ly1:sky:ly2);
kk
end
X2 = Mean (U);
imagesc (U);
Clear U
In the above, for each loop interval, I have to calculate the average of matrix U and save the resultant image, then matrix U needs to be deleted before moving to the second interval 125:1:145

请先登录,再进行评论。

采纳的回答

per isakson
per isakson 2021-1-20
Someting like this
%%
indicies = {[55:1:65], [125:1:145], [201:1:225]};
for jj = 1 : numel( indicies )
for kk = indicies{jj}
% my code
end
% save average
end

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by