フィルターのクリア

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 ビュー (過去 30 日間)
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 件のコメント
Stephen23
Stephen23 2016 年 8 月 31 日
編集済み: Stephen23 2016 年 8 月 31 日
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.

サインインしてコメントする。

回答 (1 件)

Thorsten
Thorsten 2016 年 8 月 31 日
編集済み: Thorsten 2016 年 8 月 31 日
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)))

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by