If any of you are familiar with matlab, even basic knowledge, your help would be much appreciated because of my lack of understanding/familiarity with matlab...
What I need to do is make an m-file that can extract input from a text file, change it into 16-bit binary while being precise as possible, and store that new 16-bit binary string onto another text file. The text file that I need to extract data from comprises of negatives and decimals ie. -0.0015, 0.00654. The function used to change integers to binary is "dec2bin" and only works with non-negative integers so to solve this problem, I've added and multiplied to the string to convert them to integers. I've heard that 2's complement and LSB could be used to solve this problem but I am not familiar with either. Any explanation would be useful. Thank you in advance.
Here is what I have so far:
datastr=textread(uigetfile('*.txt','Choose Text File')); %select txt file
user_entry=input('Which column would you like to extract data from? ') %select column of data
x=datastr(:,user_entry); %extracts selected column of data
%if lowest # in string is negative, adds inverse negative # to string so
%that string becomes positive
%finds value to multiply by x_1 to get the highest number < 2^16
multnum=mult*x_1 %multiplies string by multiplier found previously
roundnum=round(multnum) %rounds multnum to nearest whole number
b_16=dec2bin(roundnum,16) %converts roundnum to binary, 16-bits