variable size matrix and converting letters to numbers

조회 수: 4 (최근 30일)
Fatma Alnabrisi
Fatma Alnabrisi 2019년 11월 22일
댓글: Jan 2019년 11월 27일
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