필터 지우기
필터 지우기

For loop Stoping after saving

조회 수: 1 (최근 30일)
Maria Jaramillo
Maria Jaramillo 2018년 7월 10일
댓글: Maria Jaramillo 2018년 7월 10일
In my program I created a for loop that goes through different parameter values for processing an image and at the end it saves each image with the different parameter value. The only problem is that it only goes through the first iteration. 1. program load all paramater values 2. for loop
for JitterAmp = 0:0.33:0.66
for TarScale = 0.001:0.100:1
% does all calculations
% saves all images
if Nbits > 16
fname = [nameString, '.raw']
end
cd(oldfolder); % this contains the pathname where file is to be saved
% it then simData with bit numbers
if Nbits > 16
writeSimData (oldfolder, fName, uint32(F5));
end
end
end
The program works for only the first iteration where JitterAmp is 0 and tarScale is 0.001. After it saves it , the program stops. What can I do?

채택된 답변

Image Analyst
Image Analyst 2018년 7월 10일
You'll just have to step through it line by line to find out where it gets kicked out of the for loop, because that code looks fine to me.
Regarding your for loop values, you'd also better have a look at the FAQ: https://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F If you don't fully understand that (which it appears that you don't) then you'll run into trouble.
  댓글 수: 4
Image Analyst
Image Analyst 2018년 7월 10일
When I do it, it does JitterAmp 3 times, and TarScale 10 times for each JitterAmp, for a total of 30 times in the inner loop. You say it exits after only one time, not 30, so you ARE getting kicked out of the loop for some reason. Do you know how to set breakpoints and step through the debugger?
Maria Jaramillo
Maria Jaramillo 2018년 7월 10일
Yes! I see what you are saying. Let me see if I can figure it out. I am changing the parameters to Arrays instead as well. I read the FAQ you sent, and it makes sense that by incrementing the values by 0.33 it will not be exact.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by