부동 소수점 숫자의 이진 표현을 반환하는 Matlab 함수가 있습니까?Matlab에서 숫자의 이진 표현
4
A
답변
4
Matlab에서 Java JDK 기능을 사용할 수 있습니다.
수도 이진 문자열 표현 매트랩 플로트 (단 정밀도 32 비트 수)를 변환하기위한 짧은 대답 :
flt=3.14
import java.lang.Integer java.lang.Float;
Integer.toBinaryString(Float.floatToIntBits(flt))
긴 않음 : 부동 소수점 변환 (단 정밀도 32 비트 수)
function out=binstring2float(binstr)
% converts a binary string to float number according to IEEE754
%
% Usage:
% binstring2float('11000000010010001111010111000011')
% -3.14
%
%
% http://www.h-schmidt.net/FloatApplet/IEEE754.html
%
% Limitations:
% Rounding errors: Not every decimal number can be expressed exactly as a floating
% point number. This can be seen when entering "0.1" and examining its binary representation which is either slightly smaller or larger, depending on the last bit.
%
% Andrej Mosat, [email protected]
% 03/2012
% v0.0
% License: GNU GPL
%
% See also: FLOAT2BINSTRING
import java.lang.Long java.lang.Float;
if isequal(class(binstr), 'java.lang.String')
binstr=char(binstr);
end
if (~isstr(binstr))
error('input must be a binary string');
end
% Error handling for binary strings should be added here
% the sign is negative
if binstr(2)=='1'
binstr(2)='';
isnegative=1;
else
isnegative=0;
end
out=Float.intBitsToFloat(Long.parseLong( binstr , 2));
if isnegative
out=-out;
end
end
,536,913 : matlab에있는 바이너리 문자열 표현
function out=float2binstring(flt)
% converts a float number to binary in matlab according to IEEE754
%
% Usage:
% float2binstring(-3.14)
%
% http://www.h-schmidt.net/FloatApplet/IEEE754.html
%
% Limitations:
% Rounding errors: Not every decimal number can be expressed exactly as a floating
% point number. This can be seen when entering "0.1" and examining its binary representation which is either slightly smaller or larger, depending on the last bit.
%
% Andrej Mosat, [email protected]
% 03/2012
% v0.0
% License: GNU GPL
%
% See also: BINSTRING2FLOAT
% this is a trick to use java JDK should be installed, tested on Matlab R2010
import java.lang.Integer java.lang.Float;
if (~isnumeric(flt))
error('input must be a number');
end
out=Integer.toBinaryString(Float.floatToIntBits(flt));
end
그리고 약간의 오버 헤드를 떠 이진 문자열의 변환
1
확인이 FileExchange 제출 : 당신이 16 진수 문자열로 부동 소수점 변환 num2hex
을 사용할 수 있습니다처럼
2
것 같습니다.
+0
또한 'hex'를 사용하여 표시 방법을 변경할 수 있습니다. –
관련 문제
- 1. C에서 숫자의 이진 표현
- 2. Matlab에서 합계 표현 쓰기
- 3. NSString의 이진 표현
- 4. 이진 표현 트리 만들기
- 5. C에서의 셀 어레이 표현 (MATLAB에서)
- 6. MATLAB에서 숫자의 벡터를 C#의 목록에 추가
- 7. 부호없는 long long의 이진 표현
- 8. 4 개 옥텟의 이진 표현
- 9. json의 압축 된 이진 표현
- 10. 오디오 파일의 이진 표현 추출
- 11. 이진 트리 배열 목록 표현
- 12. 숫자의 이진 이미지에 대한 경사 보정 알고리즘
- 13. Matlab에서 이진 이미지를 그레이 스케일 이미지로 변환합니다.
- 14. matlab에서 이진 이미지의 행으로 텍스트를 나눕니다.
- 15. matlab에서 "C"프로그램으로 이진 이미지 가져 오기
- 16. MATLAB에서 이진 이미지를 어떻게 반전시킬 수 있습니까?
- 17. Matlab에서 이미지 데이터를 이진 파일로 작성
- 18. 이진 트리의 배열 표현 (인쇄 방법)
- 19. cp1252 인코딩 된 문자의 이진 표현
- 20. Perl의 부동 소수점에서 부동 소수점으로의 이진 표현
- 21. 숫자의 이진 표현에서 "1"의 짝수 카운트를 확인하는 방법은 무엇입니까?
- 22. 일부 위치 1 또는 0에서 숫자의 이진 형식으로 설정하는 방법
- 23. Ruby에서 이진 배정도 숫자의 16 진수 표현을 double로 변환하십시오.
- 24. MATLAB에서 세 행렬로 표현 된 이미지를 표시하는 방법은 무엇입니까?
- 25. 특정 숫자의 십진수 표시 방법
- 26. 이진 이미지 찾기 MATLAB에서 형태 연산자를 사용하는 교차점
- 27. matlab에서 dec2bin() 함수를 사용하여 이미지를 이진 형식으로 변환합니다.
- 28. Matlab에서 이진 행 벡터를 일반 행 벡터로 변환하는 방법은 무엇입니까?
- 29. 2 진수로 2를 나눈 부호있는 숫자 (중복 이진 표현)
- 30. 이진 비교
네이티브 MATLAB 코드는 어떻습니까? – Royi