フィルターのクリア

converting double to string

200 ビュー (過去 30 日間)
Sam Burgin
Sam Burgin 2012 年 3 月 27 日
I am making a vigenere cipher function with a varying alphabet, with inputs (message,key,alphabet)
e.g ('AVECAESAR','ROME','A':'Z')
I presume I have to convert alphabet to string, and then work the cipher out from there, but I don't know how to do this. I can't seem to get anything but 0 from alphabet.

回答 (3 件)

Thomas
Thomas 2012 年 3 月 27 日
function vigenere(message,key,alphabet)
message
key
alphabet
y=double(alphabet)
end
Where are you getting stuck?
>> vigenere('AVECAESAR','ROME','A':'Z')
message =
AVECAESAR
key =
ROME
alphabet =
ABCDEFGHIJKLMNOPQRSTUVWXYZ
y =
Columns 1 through 5
65.00 66.00 67.00 68.00 69.00
Columns 6 through 10
70.00 71.00 72.00 73.00 74.00
Columns 11 through 15
75.00 76.00 77.00 78.00 79.00
Columns 16 through 20
80.00 81.00 82.00 83.00 84.00
Columns 21 through 25
85.00 86.00 87.00 88.00 89.00
Column 26
90.00

C.J. Harris
C.J. Harris 2012 年 3 月 27 日
To convert string to double:
x = 'AVECAESAR';
y = double(x);
To convert double to string:
x = [65 86 69 67 65 69 83 65 82];
y = char(x);
  3 件のコメント
Jonathan Sullivan
Jonathan Sullivan 2012 年 3 月 27 日
It doesn't give me a "little box." It gives me ABCDEFGHIJKLMNOPQRSTUVWXYZ.
C.J. Harris
C.J. Harris 2012 年 3 月 27 日
Try this, I can assure you it will not give you any kind of Euclidean shape:
double(char('A':'Z'))

サインインしてコメントする。


Sam Burgin
Sam Burgin 2012 年 3 月 27 日
this was all down to me using freemat and not matlab itself!

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by