# Given a column matrix of numbers, how to extract some numbers that meet some condition and save them in a new matrix, if I don't know how many numbers will meet the condition?

1 visualizzazione (ultimi 30 giorni)
Cantor Set il 14 Giu 2019
Risposto: Image Analyst il 14 Giu 2019
Suppose I have a matrix R of n rows and 1 column, suppose I want to extract all numbers from matrix R that are less than or equal to 0.8 and put them in a new matrix M
the thing is I don't know how many numbers of R will meet the criteria so that I can pre-define a matrix M of zeros and replace the zeros with the new numbers that meet the criteria
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Risposte (1)

Image Analyst il 14 Giu 2019
Try
rowsToExtract = R < 0.8
M = R(rowsToExtract);
This is very very basic. Since you don't know this yet, you should probably do the 2 hours on ramp training: MATLAB Academy
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Multidimensional Arrays in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by