필터 지우기
필터 지우기

Convolution not working with 'uint16'

조회 수: 2 (최근 30일)
William Greenway
William Greenway 2022년 1월 31일
답변: Star Strider 2022년 1월 31일
I'm importing some .dat data into MATLAB to perform a discrete time convolution on a 'uint16' number.
I'm using the fread and conv functions to calculate a convolution. I find that when adding the 'uint16' variable to fread the convolution gives really small values.
test1 = [0.25 , 0.25 , 0.25 , 0.25];
% Answer gives very small convolution
x = fopen('in.dat');
A = fread(x, 'uint16');
conv(A,test1)
% Gives correct answer
z = fopen('in.dat');
C = fread(z);
v = nonzeros(C);
conv(v,test1)
Why does adding 'uint16' to the input produce the incorrect result? When looking at the difference between A and v, I cannot see any difference?

채택된 답변

Star Strider
Star Strider 2022년 1월 31일
That likely has to do with the precision of the calculations. I would convert them to double, do the calculations, and then convert back to unit16.

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by