필터 지우기
필터 지우기

Decimal to binary converter

조회 수: 4 (최근 30일)
Ujjwal Jain
Ujjwal Jain 2023년 5월 16일
답변: Walter Roberson 2023년 5월 16일
I am creating a function for decimal to binary converter to use that function in xilinx Mcode block. But it is showing error.
Error is:-
Error("dataconverter.m"): line 2:9 dec2bin is not assigned with a value before this point. A misspelling or a switch statement without otherwise statement may cause this error. Error occurred during "Block Configuration".
And the function written is:-
function B = dataconverter(A)
B = dec2bin(A,2);
end

답변 (1개)

Walter Roberson
Walter Roberson 2023년 5월 16일
I would suggest that you create your own 2-bit dec2bin:
function B = dec2bin_2bit(value)
bits = ['00'; '01'; '10'; '11'];
B = bits(value+1,:);
end

카테고리

Help CenterFile Exchange에서 FPGA, ASIC, and SoC Development에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by