필터 지우기
필터 지우기

why am i getting only the last iteration value?

조회 수: 2 (최근 30일)
karishma koshy
karishma koshy 2019년 7월 25일
댓글: Stephen23 2019년 7월 29일
i am trying to get how many times each iterations have repeated, which I have got using repmat. But at the end 'FRAM_FINAL' returns only the value of last iterations.
for FR=1:numimgs
%To read in all images in TIFF-file
output_image2=imread('C:\Users\user\Desktop\Photometrics_2x bin_video2.tif',FR);
output_image3=double(output_image2);
disp(num2str(FR))
ii=output_image3 - meanImage
I2 = mat2gray(ii);
qq=fibermetric(I2, 38,'ObjectPolarity','Bright');
[centreDark1, radiiDark1]=imfindcircles(qq, [Rmin Rmax],'Sensitivity',0.87,'ObjectPolarity','bright');
centreDark = [centreDark;centreDark1];
size(centreDark)
radiiDark = [ radiiDark;radiiDark1];
size(radiiDark)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%repmat
frame=repmat(FR,1,length(centreDark(:,1)))
FRAM_FINAL=frame(:)
end
Right now the final answer i am getting for the range FR=1:numimgs where numimgs=120
obtained result 120 expected answer: 1
120 1
120 2
120 2
120 so on
120 120
so on 120

답변 (1개)

Samatha Aleti
Samatha Aleti 2019년 7월 29일
In the given code, FRAM_FINAL value is updated at every iteration. To make the vector “FRAM_FINAL” hold the results of each iteration, I would suggest concatenating the “FRAM_FINAL” at each iteration with its respective result using cat function.
For more information on concatenation, refer the following link
  댓글 수: 1
Stephen23
Stephen23 2019년 7월 29일
Note that for efficiency the MATLAB documentation recommends preallocating the output array before the loop, and using indexing into the array within the loop:

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by