While statement not working

I'm working on a calibration code and for some reason my while statement isn't working. This is what I have:
DT = .002;
L = length(Array);
I=1;
X = .7*f;
Y = (time-.7)*f;
FD = Array;
while I <= L
A(I) = FD (I);
I = I +1;
DT = DT + .002;
if DT<=3.5 && DT >= 4
C = sum (A);
Avg_L = C/I;
I = 2*L;
end
for some reason my Avg_L is returning as empty. Does anyone know why, if so please help thanks!

댓글 수: 3

William
William 2012년 1월 18일
It's much easier for people to help you if your code is formatted correctly. In the upper right part of the questions box click the "Code" button once you've highlighted your code.
Walter Roberson
Walter Roberson 2012년 1월 18일
http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup
Image Analyst
Image Analyst 2012년 1월 18일
Looks like it's missing an end statement.

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

답변 (1개)

Image Analyst
Image Analyst 2012년 1월 18일

1 개 추천

Is this condition ever true:
if DT<=3.5 && DT >= 4
If not, C is undefined unless you previously set it equal to zero. But that would give an error, not a zero. So I guess it must be assigning C, but C=sum(A), which in in turn the sum of FD which is in turn the sum of Array. So is Array all zero?
By the way, do you know how to use the debugger - set breakpoints and examine variables? That is an essential skill that, if you had, could have solved this mystery in a few minutes.

카테고리

도움말 센터File Exchange에서 Data Type Conversion에 대해 자세히 알아보기

질문:

2012년 1월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by