Reduce Computing Time Part 2

조회 수: 2 (최근 30일)
Dejan Cvijanovic
Dejan Cvijanovic 2012년 4월 30일
Original Q:
"Hey I have somewhat tricky task of reducing computation time for one line of code in my professor's project. Is there any way to reduce the following code so that it computes at a faster rate (maybe 0.01s), right now the time to beat is 0.08s. The code is as follows:
(32 bit IEEE demultiplexed)
x = hex2float( dec2hex( fread(fid, 1, 'ubit32', 0, 'ieee-be') )) Basicslly looking for quicker way to convert the binary file to float. If you're not sure, I'm open to specifics suggestions. Also, would it be better if I wrote a code like this in C first and then let matlab read from there? Thank you."
I have tried this code:
x = fread(fid, 1, 'ubit32=>float32', 0, 'ieee-be')
and got this response back from prof;
"Dejan,
It doesn't work, function provides totally different number. For testing I would suggest to create input "number" (file, or just this 32 something variable in line). To do so I would try reverse, say take some double, convert it to float then, float2hex, then hex2dec. As a result I assume that you would have variable to play with and apply different solutions for x to covvert it back.
-Y"
Any suggestions based off this? I'm still somewhat confused. Again, can't test directly as I don't have Matlab at home.
  댓글 수: 7
Walter Roberson
Walter Roberson 2012년 4월 30일
No, ubit32 reads 32 bits, not 32 1-byte values.
Dejan Cvijanovic
Dejan Cvijanovic 2012년 4월 30일
Thanks

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

답변 (1개)

Dejan Cvijanovic
Dejan Cvijanovic 2012년 4월 30일
Should it just be
x = fread(fid, 1, 'ubit32=>double', 0, 'ieee-be')
would that solve the problem?

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by