Removing Multiples of a number from a Matrix
Show older comments
Hello all, I am very new to matlab as I am learning it for a lab i joined in school. Currently my job is only to learn matlab, functions, basics etc....
I was wondering if someone can tell me how to Remove multiples of a number from a given matrix.
For example:
Suppose i have a matrix that is
n = 1:1:20
I want to remove all the multiples of 2 from this matrix but NOT 2 such that when i displayed this "new" matrix without multiples of 2, matrix "m", it would return:
disp(m)
m = 1 2 3 5 7 9 11 13 15 17 19
would someone show me how i can do this? and also if there is a better approach to what i am doing? I want to avoid using plugins or anything, this is completely a learning experience and not something I will need to do in such large volumes that i would need a specific built in function / toolbox / plugin to do for me.
Thank you all.
Accepted Answer
More Answers (1)
Jan
on 20 Jul 2011
1 vote
The best method to learn Matlab is to use it. So how would you solve this?
One idea: Start from "n = 1:1:20" and look what happens, if the step width is set to 2: "1:2:20".
3 Comments
Mape
on 20 Jul 2011
Sean de Wolski
on 20 Jul 2011
'lookfor'
will be your friend along with help.
Jan
on 20 Jul 2011
And of course the "Getting started" chapters of the documentation.
Categories
Find more on Get Started with MATLAB 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!