Need an example of this code being run somehow? Braille English Braille is a wri
ID: 3574558 • Letter: N
Question
Need an example of this code being run somehow?
Braille English Braille is a writing system that uses binary encoding. In English Braille, each letter of the alphabet and each numberare represented by a cell that contains raised dotsat one or more of six locations, arranged as an arraywith 3 rows and 2 columns. Table 1shows the English Braille representationofthe 10 digits of the decimal system. We w represent a Braille ce in MATLAB as a 3 X2 array where raised dots are represented by ones, and zeros are used elsewhere. We will represent a sequence of n Braille cells in MATLAB as a 3 X2n array where individual cells have been concatenated horizontally. For example, the integer 2 is represented as the 3 X 2 array: 1, 0; 1,0; 0,01 and 24 is represented as the 3 X 4 array: 11, 0, 1, 1; 1, 0, 0, 1; 0, 0, 0,0]. Note that in English Bra e, numbers are preceded by a numeral sign" character, which we omit in this activity Table 1: English Braille representation (the black dots indicate the raised dots) of the ten digits of the decimalsystem. Images are from: en.wikipedia.org/wiki/English Bra n this problem, you will write two MATLAB functions that convert numbers from their Braille representations into other representations Braille conversion to double Write a function with thefollowing header: function result myBraille2Double(braille) where braille is a 3 X 2n array which represents an integer as a sequence of Braille cells as described above, and the result is the number(MATLAB class double") represented by braille Test case >re s u It- myBraille2Double 1,0, 1,1 1,0,0, 1;0,0,0,0 result r e s u It- myBraille2Double 1,0, 1,1,1,0; 1,0,0, 1,0,0 0, 0, 0, 0, 0,01) result 241 r e s u It- my Bra e2Doublei (1,0,0,1, 1,0;0, 1,1,0, 1,1;0, 0, 0, 0,0,0]) r esult 598Explanation / Answer
Code:
myBraille2Double.m file
function result = myBraille2Double(a)
result = [];
b0= [0 1; 1 1; 0 0];
b1=[1 0;0 0;0 0];
b2=[1 0;1 0;0 0];
b3=[1 1; 0 0; 0 0];
b4=[1 1; 0 1; 0 0];
b5=[1 0; 0 1;0 0];
b6=[1 1; 1 0; 0 0];
b7=[1 1; 1 1; 0 0];
b8=[1 0; 1 1; 0 0];
b9=[0 1;1 0;0 0];
[m,n] = size(a);
for i=1:2:n-1
b = a(1:m,i:i+1);
if(isequal(b,b0))
result(end+1) = '0';
elseif(isequal(b,b1))
result(end+1) = '1';
elseif(isequal(b,b2))
result(end+1) = '2';
elseif(isequal(b,b3))
result(end+1) = '3';
elseif(isequal(b,b4))
result(end+1) = '4';
elseif(isequal(b,b5))
result(end+1) = '5';
elseif(isequal(b,b6))
result(end+1) = '6';
elseif(isequal(b,b7))
result(end+1) = '7';
elseif(isequal(b,b8))
result(end+1) = '8';
elseif(isequal(b,b9))
result(end+1) = '9';
else
fprintf('-');
end
end
end
test.m file
a = [1 0 1 1;
1 0 0 1;
0 0 0 0];
result = myBraille2Double(a);
fprintf('result is: ');
for i=1:length(result)
fprintf('%s',char(result(i)));
end
fprintf(' ');
Output:
result is: 24
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.