Quantcast
Channel: MATLAB Central Newsreader - tag:"homework"
Viewing all articles
Browse latest Browse all 36

Retrieving only odd or even numbers from a matrix

$
0
0
Within a matrix, I want to be able to retrieve only odd numbers within the matrix, and place that into its own matrix.

What I have right now is:

x = randn(1,100);
odd = mod(x, (x/2))

I'm not able to get the new matrix, odd, to print with the odd values from x, even though I divided by 2, in order to return any values with a remainder. I get an error instead, stating that my second argument of the function mod() is wrong.

Where am I going wrong with my code?

Thanks for the help!

Viewing all articles
Browse latest Browse all 36

Trending Articles