Matlab rounding to zero?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have some arrays that are ADC values and I simply need to convert them into actual voltage. This is easily done by ADC*Gain however when I do this Matlab gives me zero every time. Below is the code and I am multiplying (.05/65536), the ADC values are int16 data type. My ADC values are like 6000-8000 and so I should be getting around .005 or on the order of mV for my voltage. Any help would be appreciated.
for i=1:10000
A(i,:) = (ans.Channels(1,1).Acquisitions(i,:))*(.05/65536);
end
댓글 수: 0
채택된 답변
Gurudatha Pai
2011년 6월 17일
Like Sean said, convert all variables to some floating point format. You might do something like,
for i=1:10000
A(i,:) = double((ans.Channels(1,1).Acquisitions(i,:)))*(.05/65536);
end
댓글 수: 0
추가 답변 (1개)
Sean de Wolski
2011년 6월 17일
int16((.05/65536))
ans =
0
Multiplication by zero is always zero... Convert to single or double precision.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!