필터 지우기
필터 지우기

Not enough values for typecast

조회 수: 3 (최근 30일)
Aaron Smith
Aaron Smith 2017년 3월 8일
편집: Jan 2017년 3월 14일
I'm attempting to use discretize to bin a large matrix. The problem is that the values are in int32 format. I am attempting to convert the data to uint32 using typecast but the "not enough arguments" arises. What do I need to change or specify to rectify this?
  댓글 수: 1
Adam
Adam 2017년 3월 8일
편집: Adam 2017년 3월 8일
It would help if you show your code otherwise we don't know what you are doing wrong.
Can you not just cast using e.g.
output = uint32( input );
? I'm not sure typecast is really what you want to be using. Also if you have negative data this will all get lost if you just cast so you would need to scale and shift your data.

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

답변 (1개)

Jan
Jan 2017년 3월 8일
편집: Jan 2017년 3월 14일
Casting means changing the values to match the new type:
a = int32([15, -1])
b = uint32(a) % Equivalent: cast(a, 'uint32')
Now b is [15, 0]: The first value is kept, but the second is set to 0 because it is the nearest possible conversion.
With typecasting the bitpatterns are not touched, such that the values can change:
typecast(a, 'uint32')
>> [15 4294967295]
This needs two inputs (seeing your code would reveal what is missing) and the value of uint32(-1) is changed.
[EDITED] Typecasting a vector of 3 uint8 values:
x = uint8(1:3)
to an uint32 must fail, because the input contains to few bytes. A multiple of 4 bytes are required for this operation. This causes the error "Not enough values for typecast".
I assume, you want to cast the values, not to typecast.

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by