how to store input value to an array
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
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
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
2015-9-29
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Numeric Types 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!