MATLAB Answers

How do I convert the binary valued column to decimal?

16 views (last 30 days)
Jay Vaidya
Jay Vaidya on 28 Apr 2020
Commented: darova on 16 May 2020
cadence_data = readtable('just_adder_1p2_ABS_matlab.csv','ReadVariableNames',0);
cadence_data = cadence_data{:,:};
cadence_data(1,:) = [];
%% bi2de
% [rows_A cols_A] = size(cadence_data);
cadence_data = cellfun(@str2double,cadence_data);
for i = 1:1:size(cadence_data,1)
cadence_data(i,7) = bi2de(cadence_data(i,4));
end
Error:
Error using bi2de>validateInputs (line 81)
The elements of the matrix are larger than the base can represent.
Error in bi2de (line 35)
[b_double, inType, p, msbFlag] = validateInputs(b, varargin{:});
Error in cadence_just_adder (line 15)
cadence_data(i,7) = bi2de(cadence_data(i,4));
The excel file attached has binary valued cells (columns 2,4 and 6). How can I convert those 16 bit binary bits in to decimal values?
Thanks in advance
  2 Comments
Jay Vaidya
Jay Vaidya on 28 Apr 2020
It is a 16 bit binary data
For example:
1.01111E+15 when you see as a expanded column in excel, it will be 101111....

Sign in to comment.

Accepted Answer

darova
darova on 28 Apr 2020
Try this
A = readtable('just_adder_1p2_ABS_matlab.csv');
A1 = table2array(A(:,2));
A2 = bin2dec(num2str(A1));
  3 Comments

Sign in to comment.

More Answers (1)

KSSV
KSSV on 28 Apr 2020
  1. Load data from csv files using csvread.
  2. Use the function bin2dec to convert binary to decimal.
  3 Comments
Jay Vaidya
Jay Vaidya on 28 Apr 2020
I get the following error
Error using bi2de>validateInputs (line 81)
The elements of the matrix are larger than the base can represent.
Error in bi2de (line 35)
[b_double, inType, p, msbFlag] = validateInputs(b, varargin{:});
Error in cadence_just_adder (line 15)
cadence_data(i,7) = bi2de(cadence_data(i,4));

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!