how to store input value to an array

if input is [ 1 2 1 1 1 2 2 1 1 2 1 1 1] how to store in an array
kindly help me with syntax

5 件のコメント

Stephen23
Stephen23 2015 年 9 月 29 日
編集済み: Stephen23 2015 年 9 月 29 日
[ 1 2 1 1 1 2 2 1 1 2 1 1 1] is already an array. A vector is an array, so what is your question actually about?
Sorry we can't read minds, your explanation actually is required so we understand what you want to do.
Dhipikaa Sri Dhamotharan
Dhipikaa Sri Dhamotharan 2015 年 9 月 29 日
syntax to store this input
Walter Roberson
Walter Roberson 2015 年 9 月 29 日
x = [ 1 2 1 1 1 2 2 1 1 2 1 1 1]
Pablo Sánchez
Pablo Sánchez 2020 年 10 月 10 日
And how could I store an input in the sense of:
password = input('Please introduce me a 9 character password: ', 's');
I know I'm not restricting the input but it doesn't matter. I just want to store this input in an array
And I guess I can't do the following:
password = [input('Please introduce me a 9 character password: ', 's')];
Walter Roberson
Walter Roberson 2020 年 10 月 10 日
In the code
password = input('Please introduce me a 9 character password: ', 's');
then password would already be an array.
If you wanted a collection of such things, you could use a cell array or you could use a string array. In either of those two cases,
all_passwords{end+1} = password;
The difference would be whether you initialized
all_passwords = cell(0); %cell array
all_passwords = strings(0); %string array

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

回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 9 月 29 日

0 投票

x = [ 1 2 1 1 1 2 2 1 1 2 1 1 1];
Y(2,:) = x; %store X as second row of matrix Y

カテゴリ

ヘルプ センター および File ExchangeNumeric Types についてさらに検索

タグ

タグが未入力です。

質問済み:

2015 年 9 月 29 日

コメント済み:

2020 年 10 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by