typecast in MatLab to convert data type

26 sec read

We need to get real-time neural signal from Hitachi’s ETG4000. Hitachi provides a MatLab script “RealtimeOT” to get data from a parallel port and convert the binary data to float. Here is what they did:

floatdata =fread(fp,4,'float');

This piece of code will be called a few hundred times per second. Converting data using file is too slow. As a result, the signal we get is not real time at all (delay up to 10s). Indeed, there is a very simple way to do this (typecast):

floatdata=typecast(uint8(bindata), 'single');

Then the program runs very smoothly and there is no delay.

nirs2img, create an image file from NIRS data

Update 2021/2/27: If you find griddata3 not working, try to change griddata3 to griddata. I was asked where to get nirs2img script. Here it...
Xu Cui
51 sec read

mergefile.m – a MatLab script to merge CSV files

My wife asked me to write a script to merge some csv files she has. Usually this can be accomplished by a simple command in...
Xu Cui
35 sec read

xjview 9.6 released

In this version, we modified the templates for 3-D render view and use a high-resolution template. It also includes a few scalp view. You...
Xu Cui
31 sec read

One Reply to “typecast in MatLab to convert data type”

  1. I have read 64 data from my serial port. each two bytes should be combined together to form one 16 bit data. So, what is the function that will make the operation to the whole data. Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *