variable size matrix and converting letters to numbers

3 次查看(过去 30 天)
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.
Thanks
  2 个评论
Fatma Alnabrisi
Fatma Alnabrisi 2019-11-25
My input at the sender side:
the user is asked to enter the key which has to be a sequare matrix K (nxn) .
--> I need to get the dimension of the key matrix.
the user then enters the plain text.
I need to convert the letters into numbers and store them in matrix P (nxm).
( A --> 1 , B --> 2 , ....., Z --> 26 , ... )
if the length of the plaint text is less than n*m, i need to fill the matrix with zeros.
Then some manipulations on the K matrix and P matrix have to be done to get the ciphertext matrix and convert the numbrs back into letters.
Jan
Jan 2019-11-27
@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.

请先登录,再进行评论。

采纳的回答

Jan
Jan 2019-11-22
"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.
  3 个评论
Jan
Jan 2019-11-23
@Fatma: Before the readers can help you efficiently, you have to explain the problem with more details. Currently we know only a rough explanation and it is unclear, which kind of help you need. It matters if the input should be just one or 2 sentences, or 500 pages of text.
Can you post a small and meaningful example of the wanted inputs and outputs?
Fatma Alnabrisi
Fatma Alnabrisi 2019-11-25
I've added some extra details. can you please look at them and help me out.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by