Borrar filtros
Borrar filtros

I have a matrix 20X1. I want to read all the elements of c2 and put the condition as if element of c2 is greater that zero and less than 70 then display that element else return. how should I do?

2 visualizaciones (últimos 30 días)
c2 =
[ 1.3589]
[ 7.9773]
[28.2728]
[28.2728]
[ 0.8705]
[ 7.4681]
[28.2728]
[37.0303]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
[ 0]
  1 comentario
Stephen23
Stephen23 el 31 de Ag. de 2016
Editada: Stephen23 el 31 de Ag. de 2016
Duplicate:
@Sachin Patil: actually it makes it harder for us to help you when you ask the same question in multiple locations. Then we cannot keep track of your information and explanations, and also what answers you have been given.

Iniciar sesión para comentar.

Respuestas (1)

Thorsten
Thorsten el 31 de Ag. de 2016
Editada: Thorsten el 31 de Ag. de 2016
for i = 1:numel(ca)
if ca{i} > 0 & ca{i} < 70
% do this
else
% do that
end
end
If you just want to extract the elements that fulfil the condition:
First remove the empty elements:
ca2 = ca(~cellfun(@isempty, ca))
Next use logical indexing to pick the elements from ca2:
cell2mat(ca2(cellfun(@(c) 0 < c & c < 70 , ca2)))

Categorías

Más información sobre Data Import and Export en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by