## Copyright (c) 2012 Juan Pablo Carbajal ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . ## -*- texinfo -*- ## @deftypefn {Function File} {@var{y} =} deserializeInt (@var{x}) ## Coverts bytes to an integer. ## ## It takes a 2*N-by-1 array as input and consumes entries in pairs, the first as the LSB ## and the second as the MSB to generate a single number. ## ## Example: ## @example ## x(1,:) = getbit (707,1:8); ## x(2,:) = getbit (707,9:16); ## LSB = bitpack (x(1,:),"uint8"); ## MSB = bitpack (x(2,:),"uint8"); ## ## serialized = [LSB,MSB], ## y = deserializeInt (serialized), ## ## serialized = ## 195 2 ## y = 707 ## @end example ## ## @seealso{srl_plot} ## @end deftypefn ## Author: Juan Pablo Carbajal function y = deserializeInt (data) y = bitpack ( cell2mat( arrayfun( @(x)bitget(x,1:8), data, "UniformOutput", false ) )', "uint16"); y = double (y); endfunction %!demo %! x(1,:) = bitget (707,1:8); %! x(2,:) = bitget (707,9:16); %! LSB = bitpack (x(1,:),"uint8"); %! MSB = bitpack (x(2,:),"uint8"); %! %! serialized = [LSB,MSB], %! y = deserializeInt (serialized),