필터 지우기
필터 지우기

Correct use of uint32

조회 수: 4 (최근 30일)
John
John 2011년 8월 31일
When I do the line
k = idx1* uint32(30e6) + idx2* uint32(0) + idx3* uint32(30e6);
I get an error "Integers can only be combined with integers of the same class, or scalar doubles." However, when I do:
idx1* uint32(30e6);
or
idx1* uint32(30e6) + idx2* uint32(0);
it works. Where am I going wrong? idx is a vector produced by:
idx1 = ( a < b )
where a and b are vectors.
  댓글 수: 1
Oleg Komarov
Oleg Komarov 2011년 8월 31일
I get the error anytime I use idx1*uint32(30e6);
From the code you gave us it should issue the error anytime. Provide more code to understand what's going on.

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

채택된 답변

Friedrich
Friedrich 2011년 8월 31일
Hi,
idx1 is a logical vector. So the error can be raised with:
logical(1)*uint32(2)
To get it working, cast idx1 to uint32:
uint32(logical(1))*uint32(2)
ans =
2
So in your case:
k = uint32(idx1)* uint32(30e6) + uint32(idx2)* uint32(0) + uint32(idx3)* uint32(30e6);

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by