bitget function is not invoking output bits in a vector
显示 更早的评论
k=k+1; %% k is counter and its chainging even more than (length(A))
for t = 1:1:length(A) %% A is a vector contains 8 elements
recovered_bits(1,k)= bitget(A(1,t),1); % extract LSB of each element in array and put them (LSB) in recovered_bits vector
k=k+1;
end
%% Output ----> recovered_bits = [] knowing that i trying to preallocate the vector previously
3 个评论
KALYAN ACHARJYA
2018-11-26
What is A here?
madhan ravi
2018-11-26
编辑:madhan ravi
2018-11-26
Anmar Mohammed
2018-11-26
采纳的回答
更多回答(2 个)
Steven Lord
2018-11-26
Why loop?
r = randi([0 intmax('int8')], 8, 1, 'int8');
recovered_bits = bitget(r, 1);
result = [r, recovered_bits, mod(r, 2)]
The second and third columns of result should be the same.
1 个评论
Anmar Mohammed
2018-11-26
编辑:Anmar Mohammed
2018-11-26
KALYAN ACHARJYA
2018-11-26
编辑:KALYAN ACHARJYA
2018-11-26
Initiallize k=1, otherwise K is not defined
k=1; %% k is counter and its chainging even more than (length(A))
for t = 1:1:length(A) %% A is a vector contains 8 elements
recovered_bits(1,k)= bitget(A(1,t),1); % extract LSB of each element in array and put them (LSB) in recovered_bits vector
k=k+1;
end
2 个评论
KALYAN ACHARJYA
2018-11-26
编辑:KALYAN ACHARJYA
2018-11-26
For example I have choosen different A
A=[4 6 7 4 3 0 8 4];
for t=1:1:length(A) %% A is a vector contains 8 elements
recovered_bits(t)=bitget(A(1,t),1); % extract LSB of each element in array and put them (LSB) in recovered_bits vector
end
%% Output ----> recovered_bits = [] knowing that i trying to preallocate the vector previously
disp(recovered_bits);

Anmar Mohammed
2018-11-26
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!