Continually prompt for the input of 3x1 column vectors
9 views (last 30 days)
Show older comments
Samuel Jones
on 21 Dec 2018
Answered: Samuel Jones
on 27 Dec 2018
Hello,
I am trying to find a way for my code to continually prompt for the input of 3x1 column vectors, and then create a 3xn matrix where n is the number of vectors the user inputs and each column of the matrix is one of the vectors. I also need to be able to label each vector, although the labels should not be present alongside the matrix. As an example, if the user needed to input three vectors, it would function something like this:
label1 = [1;2;3]
label2=[4;5;6]
label3=[7;8;9]
The resulting matrix would be
group=[1 4 7; 2 5 8; 3 6 9]
I am a bit of a novice with matlab and I am not sure where to begin with this code, aside from possibly using a question dialog box after each user input to determine if more input will occur. The main struggle is the continuous input.
Any help would be greatly appreciated
Thank you
1 Comment
Stephen23
on 22 Dec 2018
Edited: Stephen23
on 22 Dec 2018
"I am a bit of a novice with matlab and I am not sure where to begin with this code"
Start by reading this:
Probably the easiest ways to let your user enter data is either with a GUI, e.g. uitable (intuitive but slow), or by simply writing functions and letting the user decide how they want to define their own data (faster and much more efficient).
Accepted Answer
More Answers (1)
madhan ravi
on 21 Dec 2018
result=[label1(:) label2(:) label3(:)]
2 Comments
madhan ravi
on 22 Dec 2018
Yes make a loop and save each vectors as a column and then concatenate them.
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!