How do I make the user input values into a matrix?
17 views (last 30 days)
Show older comments
HELLO!!!
kinda new to MATLAB, and I'm trying to figure out a way to ask the user to fill in a matrix and at the same time store something like a counter to know how many values are there in the matrix. from that, I could be able to find out if the number of values entered are odd or even, and how to absolute each value.
for example: input values: 9 -8 7 -6 5 these are odd numbers and there abs values are 9 8 7 6 5
0 Comments
Accepted Answer
dpb
on 12 Dec 2015
doc input
>> x=input('Enter an array of values in []: ')
Enter an array of values in []: [1 2 3 -8 2:pi:12]
x =
1.0000 2.0000 3.0000 -8.0000 2.0000 5.1416 8.2832 11.4248
>> n=length(x)
n =
8
>> e=mod(x,2)==0
e =
0 1 0 1 1 0 0 0 0 0 0 0 0
>>
Read "Getting Started" section in documentation and work thru examples to get an overview of "how Matlab works"...
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!