variable size matrix and converting letters to numbers

3 Ansichten (letzte 30 Tage)
Fatma Alnabrisi
Fatma Alnabrisi am 22 Nov. 2019
Kommentiert: Jan am 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.
Thanks
  2 Kommentare
Fatma Alnabrisi
Fatma Alnabrisi am 25 Nov. 2019
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 am 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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Jan
Jan am 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.
  3 Kommentare
Jan
Jan am 23 Nov. 2019
@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 am 25 Nov. 2019
I've added some extra details. can you please look at them and help me out.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by