how can select a specific bits from logical vectors !

3 ビュー (過去 30 日間)
Furat Alobaidy
Furat Alobaidy 2019 年 10 月 16 日
コメント済み: Furat Alobaidy 2019 年 10 月 25 日
Hi , i need your help please ,
i have vector contains hex numbers such as :(16-bits)
(0000 0011 1100 0000)
i need select the middel bits from ( b7-b10) then read its as decimal asuch as = 15
i alraedy did that as in the code , but the problem is just work with last row in the vector for my data base ('address.xlsx')! this data base contains 16 rows!
i need find and stor the resuts as vecotr for all my data base numbers not just last elment!
clc;
clear all;
[~,~,dat]= xlsread('address.xlsx');
num=dat(:,1);
for n=1:numel(num)
b=hex2dec ([dat(:,1)]);
b1 = hex2dec('000fff0');
% b = hex2dec ('6e206b'); % for example its work with one elemnt
format hex;
x=bitand(b1,b);
cc=dec2hex(x);
bin=hexToBinaryVector(cc);
ccz=bin((end-flip(7:10)+1));% how can expand this term for all vector!
bp=num2str(ccz);
bp11= bp(find(~isspace(bp)));
v1= bin2dec(bp11);
end

採用された回答

Divya Gaddipati
Divya Gaddipati 2019 年 10 月 23 日
Hi,
Making the following changes to your code will solve the issue:
  • Line - 6
b = hex2dec(dat{n}); % since the variable “dat” is a cell array
  • Line - 16
v1{n} = bin2dec(bp11) % since you want to store the result of every element
  1 件のコメント
Furat Alobaidy
Furat Alobaidy 2019 年 10 月 25 日
thanks a lot for your help

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by