How to take value of particular interval from a column?

4 ビュー (過去 30 日間)
RS
RS 2013 年 8 月 18 日
there is column having arbitrary value from 0-1200 but I have to take only 600-800 from that column? How can I ?
1100 4.7693 13.746 0.08116 308.6983
1160 4.5938 13.24 0.08112 308.68619
1220 4.5577 13.136 0.08109 308.67407
1280 4.9122 14.158 0.08105 308.66205
1340 5.0029 14.419 0.08102 308.64944
1400 4.7408 13.664 0.08099 308.63684
20 4.7447 13.675 0.08096 308.62524
80 4.8635 14.017 0.08093 308.61322
140 4.7867 13.796 0.0809 308.60065
200 4.6726 13.467 0.08088 308.58905
260 4.7121 13.581 0.08086 308.57675
320 4.6942 13.529 0.08083 308.56442
a=xlsread('Book1.xlsx');
k=1;
for i=1:length(a(:,1))
if 600<=a(i,1)>=800
a(i,1)=NaN;
k=k+1;
end
end

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 18 日
a(a(:,1)>800 & a(:,1)<1000,1)=nan
  2 件のコメント
RS
RS 2013 年 8 月 18 日
result is not coming How can I?
How can I improve my result ? result is not coming ? there is column having arbitrary value from 0-1200 but I have to take only 600-800 from that column? How can I ?
1100 4.7693 13.746 0.08116 308.6983
1160 4.5938 13.24 0.08112 308.68619
1220 4.5577 13.136 0.08109 308.67407
1280 4.9122 14.158 0.08105 308.66205
1340 5.0029 14.419 0.08102 308.64944
1400 4.7408 13.664 0.08099 308.63684
20 4.7447 13.675 0.08096 308.62524
80 4.8635 14.017 0.08093 308.61322
140 4.7867 13.796 0.0809 308.60065
200 4.6726 13.467 0.08088 308.58905
260 4.7121 13.581 0.08086 308.57675
320 4.6942 13.529 0.08083 308.56442
a=xlsread('Book1.xlsx');
k=1;
for i=1:length(a(:,1))
if a(a(i,1)>800 & a(i,1)<1000,1)=NaN;
a(i,1)=NaN;
k=k+1;
end
end
How can I improve result?
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 8 月 18 日
編集済み: Azzi Abdelmalek 2013 年 8 月 18 日
a=xlsread('Book1.xlsx');
k=1;
for i=1:numel(a(:,1))
if a(i,1)>800 & a(i,1)<1000
a(i,1)=nan;
end
end

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

その他の回答 (1 件)

Image Analyst
Image Analyst 2013 年 8 月 18 日
編集済み: Image Analyst 2013 年 8 月 18 日
To extract elements in that range to a new array, try this:
rowIndexesInRange = data(:, column) >= 600 & data(:, column) <= 800;
extractedValues = data(rowIndexesInRange , column);
Note: extractedValues will probably be a smaller size than data. If you want the elements in the same locations but just want others set to zero or some other value, then you'll have to set do
data(~rowIndexesInRange, :) = 0;
This will just zero out elements not in the range and leave elements in range in their original location.
  7 件のコメント
RS
RS 2013 年 8 月 18 日
In that row all element should be NaN? How can I?
Image Analyst
Image Analyst 2013 年 8 月 18 日
編集済み: Image Analyst 2013 年 8 月 18 日
If "take" means "set to nan" for you (though that seems like a strange definition of take to me), then do this:
data(~rowIndexesInRange, :) = nan;
result will be in data, rather than extractedValues. )You will probably also need cell2mat to turn your cell array from xlsread() into a matrix.)

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by