I'm trying to convert the text into binary and then i want to make the 4 bits chunks.
Show older comments
But the problem is that how to make the total size at the output for example: 001010101010001110101110111010110101.
its mean that i have only 1 row and 36 columns.
but i can't do it.
please help me out!
clc;
close all;
clear alll;
% I'm trying to convert the Hello World into binary
message = ('Hello world');
A = dec2bin(message, 8); % Now to convert the charactors into 8 Bits using ASCI.
[r c]=size(A);
cc=struct([]);
A=convertCharsToStrings(A);
for j=1:1:r;
z=A(j,:);
cc=cat(2,cc,A(j,:));
end
disp(cc);
Answers (2)
Is this what you are going for?
message = 'Hello world';
A = dec2bin(message, 8);
cc = reshape(A.',1,[])
4 Comments
Naveed
on 30 Apr 2024
Ok. Please describe what you want.
You said 1x36, but the result has 88 bits (11 symbols at 8 bits per symbol), so that's inconsistent.
You said chunks of 4 bits, but that would only allow encoding of 16 distinct symbols. And 4 bits per symbol with 11 symbols would be 44 bits, not 36.
Clearly I'm very confused. Can you please help me out by providing a sample message and corresponding output? The message can be shorter than 'Hello world' if that's convenient.
Naveed
on 1 May 2024
message = 'Hello world';
A = dec2bin(message, 8);
B = reshape(A.',4,[]).'
size(B)
message = 'Hello world';
A = dec2bin(message, 8)
B = reshape(A.',1,[])
2 Comments
Naveed
on 1 May 2024
"Now make the 4bits chunks and then check the size."
message = 'Hello world';
A = dec2bin(message, 8)
B = reshape(A.',1,[]);
C = reshape(B,4,[]).'
size(C)
Categories
Find more on Test Model Components in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!