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

 Akzeptierte Antwort

dpb
dpb am 12 Dez. 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"...

Weitere Antworten (0)

Produkte

Gefragt:

am 12 Dez. 2015

Kommentiert:

am 12 Dez. 2015

Community Treasure Hunt

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

Start Hunting!

Translated by