フィルターのクリア

How do I turn a string into a matrix but have each character in the string in a different cell?

2 ビュー (過去 30 日間)
So I'm trying to make a password checker for my programming final and its supposed to take an input from the user and test it for all these requirements. So my password that meets all the requirements is Ab1@cd and I want the make it so that is stored as a matrix like this [A b 1 @ c d]. Ive tried several different things but still cant get it to do what I want. Please help :(

採用された回答

Sammit Jain
Sammit Jain 2017 年 11 月 27 日
Here, I think this should do what you want to do. Actually MATLAB by default stores a string such that you can reference it by indices. Here's something that will do the job:
mystring = 'Ab1@cd';
myMat = mystring(:);
%Using the colon(:) will list out all elements in the string, and you're putting that list into a matrix
Hope this helps. Cheers.
  2 件のコメント
Zachary  Fancher
Zachary Fancher 2017 年 11 月 27 日
Thank You! You made my day! I've spent the last two hours messing with for and While loops XD
Stephen23
Stephen23 2017 年 11 月 27 日
編集済み: Stephen23 2017 年 11 月 27 日
Both myString and myHat are matrices, so all you did is convert a 1x6 char matrix into a 6x1 char matrix. I don't really see the point.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by