How to create an array with user inputs?

45 views (last 30 days)
Soeun Lee
Soeun Lee on 5 Aug 2021
Hello, I am trying to create an array with user inputs. For example, if the user types 3, 5, 7, the array comes out to be [3,5,7]. How can I do this? Thanks in advance for your help!

Answers (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 Aug 2021
You can consider using input() prompt. See this doc with examples: https://www.mathworks.com/help/matlab/ref/input.html?s_tid=srchtitle
  1 Comment
Soeun Lee
Soeun Lee on 5 Aug 2021
Thanks for your answer. I am using the input() prompt, but the only problem is I don't know how to put the user inputs into an array. Any ideas?

Sign in to comment.


Sulaymon Eshkabilov
Sulaymon Eshkabilov on 5 Aug 2021
A = [input('ENTER your matrix: ')]

Community Treasure Hunt

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

Start Hunting!