removing irrelevant datasets from variable

i have a data set of size Data{301*4090}. From this data set I want to remove data which is less than a particular range. So I start analyzing the Data(1) and check if the values are less than -500 or greater than 500 I should keep this data set otherwise I should eliminate this data set.
So I use a nested for loop first which runs from 1 to 301 and second which runs from 1 to 4090. I use a if condition to check for the above conditions.
for i = 1:1:len(1)
for j = 1:1:4090
if (newsensorData(i,j)<=-500)||(newsensorData(i,j)>=500)
modsensorData(i,j) = newsensorData(i,j);
else
sprintf('This data is not relevant for further processing');
end
end
end
My problem is I want that if in Data(1) my condition is fulfilled I should stop checking Data(1) and then check Data(2).
How do I make this work. Please excuse me if I did not frame my question properly.
Thanks.

5 件のコメント

José-Luis
José-Luis 2013 年 5 月 21 日
編集済み: José-Luis 2013 年 5 月 21 日
What are Data(1) and Data(2)? The only variables that are defined in your code are newsensorData and modsensorData
Jatin Arora
Jatin Arora 2013 年 5 月 21 日
Sorry Jose newsensorData is my initial variable {301*4090} and modsensorData is what I am trying to save.
José-Luis
José-Luis 2013 年 5 月 21 日
編集済み: José-Luis 2013 年 5 月 21 日
I still don't understand what you are trying to do. Is it what Walter suggests? Also, you didn't really answer my question. What are Data(1) and Data(2)?
What does Data{1} look like? Are you aware that the curly braces {} are normally used in the context of cell arrays?
Jatin Arora
Jatin Arora 2013 年 5 月 21 日
newsensorData is my variable of dimensions 301*4090. I framed the question by using imaginary variables Data, Data(1) and Data(2) but i copied the same code as it was in my MATLAB. I apologize for this confusion.
I have modified the code and now I think it works fine
len = size(newsensorData)
for i = 1:1:len(1)
for j = 1000:1:4000
if (newsensorData(i,j)<=-500)||(newsensorData(i,j)>=500)
modsensorData(i,1000:4000) = newsensorData(i,1000:4000);
end
end
end
José-Luis
José-Luis 2013 年 5 月 21 日
Maybe it's just one of those days, but I just don't get what you are trying to do. Anyway, I'm glad it worked out for you.

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

回答 (2 件)

Walter Roberson
Walter Roberson 2013 年 5 月 21 日

0 投票

if condition
...
else
fprintf('This data is not relevant for further processing');
break; %notice this!
end
Iain
Iain 2013 年 5 月 21 日

0 投票

IgnoredValue = NaN; % (or 0, or inf, or some known bad value)
modsensorData = newsensorData;
modsensorData(modsensorData > 500) = IgnoredValue;
modsensorData(modsensorData < -500) = IgnoredValue;

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

質問済み:

2013 年 5 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by