Need help with factorizing array of numbers
Afficher commentaires plus anciens
hi there,
say you have an array of numbers x =[94 89 124 120 150] how can i find factors of this array, i mean break each number in the array to its primes. i know the function is factor(x). but it only applies to a scalar value not an array. i tried putting it on a loop
x =[94 89 124 120 150] ;
for i = 1:length(x)
facts_x(i) = factor(x(i))
end
but this i realized gives me an error because the loop runs only in the length of x the facts_x ends up bigger because factor answer is stored as an array. please help. thanks SN
1 commentaire
José-Luis
le 26 Fév 2013
Try storing it in a cell array instead:
facts_x(i) = {factor(x(i))}
Réponse acceptée
Plus de réponses (1)
Ahsan Khan
le 27 Fév 2013
0 votes
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!