couldn't figure out what's not working
조회 수: 2 (최근 30일)
이전 댓글 표시
hi, this is the code
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151010/image.jpeg)
executing => THIS IS THE FIRST ITERATION
tab =
7 8 9 10 11 12 13 14 15 16 17 21 22 25
f1 =
236
m1 =
12
r1 =
0
wi =
0
f =
240
but the real result is
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/151011/image.jpeg)
f1 =
236
m1 =
11
r1 =
16
wi =
1
f =
232
'f' should be 232 not 240 and it is the same code, where is this 240 coming from??
thank you
댓글 수: 0
채택된 답변
Ingrid
2015년 6월 9일
the problem is that your f1 is not a double but an integer hence the division also gives an integer
if you cast f1 to be a double you should get the expected result
f1 = double(f1);
m1 = floor(f1/delta)
etcetera
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Identification에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!