MATLAB Answers

variable size matrix and converting letters to numbers

1 view (last 30 days)
Fatma Alnabrisi
Fatma Alnabrisi on 22 Nov 2019
Commented: Jan on 27 Nov 2019
Hello everyone,
I'm working on a college project that encrypt text messages using LU decomposition and matrix inverse methods.
I need your help in how to let the user enter a variable size matrix to store the key and another for the plain text.
Moreover, how could I convert the letters into certain numbers.
Another last question, how to fill the array with null operators in case the plain text is too short to fill it.
Jan on 27 Nov 2019
@Fatma: Please consider, that the readers do not know, what you exactly want. While "My input an the sender" is most likely clear to you, there is no chance to guess, what this eactly means. Perhaps "sender" means a TCP/IP connection, or the inputs of a function, or a remote or local GUI, a web service, etc. "Asked to enter the key" can mean a variety of things also.
Converting the characters to number is easy:
num = txt - 'A' + 1;
Filling a matrix with zeros is easy also:
M = zeros(n, n);
Now inserting the existing values in column order:
M(1:m) = num;
I do not understand, what m is.
The description is still far too vague to offer an explicite suggestion.

Sign in to comment.

Accepted Answer

Jan on 22 Nov 2019
"user enter a variable size matrix": It depends on how you want to implement this: by a GUI, as Matlab code, as text file, in Excel?
"another for the plain text": Of course a text file would be my first idea. But a GUI with an edit field would be sufficient also.
"how could I convert the letters into certain numbers": Simply by using the double() command, which converts the characters to their ASCII codes.
"fill the array with null operators": What is a "null operator"? I guess simply using zeros might be fair.
Fatma Alnabrisi
Fatma Alnabrisi on 25 Nov 2019
I've added some extra details. can you please look at them and help me out.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!