Ignore elements in an array.

Hi. I am to plot Value vs. Time using the following data from a databasefile which I haven't included. But the output looks like the following:
Value =
0.4100
0.2500
0.3340
0
0.5500
0.6250
0.7500
0.3330
0
Time =
1.0e+003 *
3.4018
3.4431
3.4507
3.4563
3.4585
3.4684
3.4793
3.4819
3.5181
Value = []; % create a 0-by-0 matrix
Time = [];
for i = 1:k
ValueID = ValueList(i,n);
if ValueID > 0 % some Value id's are negative or zero - these are irrelevant
index = find(ismember(cell2mat(Table1(:,1)),ValueID)==1); % locates the index
Output = Table{index,2};
ValueList(i,5) = Output; % Takes values from 5th column in databasefile
ValueList(i,6) = 39.3700787*gwdWt; % convert from metres to inches and takes values from sixth row in databasefile
%else
end
Value = [Value;ValueList(i,6)] % structures value as a row.
Time = [Time; ValueList(i,2)]
end
So what I am asking is, how do I ignore the following
0 and 3.4563,
also
0 and 3.5181?
Is that clear?

 채택된 답변

Matt Kindig
Matt Kindig 2012년 10월 16일

0 개 추천

Are Value and Time the same size? If so, you can just do this, using logical indexing (no loops):
deleteThese = (Value <= 0);
ValuesWithDeletions = Value(~deleteThese);
TimeWithDeletions = Time(~deleteThese);

댓글 수: 5

T
T 2012년 10월 16일
I think so. What if they aren't?
Image Analyst
Image Analyst 2012년 10월 16일
If they aren't the same size, you'd better figure out why not, or how to interpret that situation, because it won't make sense and the code won't run.
T
T 2012년 10월 16일
편집: T 2012년 10월 16일
Okay. What was provided above works. However, would you know why I would get a continuous plot as opposed to a discrete?
Should I just use stem as opposed to plot?
What is a "discrete" plot vs. a "continuous" plot, in this context? Do you just mean a plot with connected points (i.e. lines), as opposed to just markers? If so, you can easily turn off the line to display only the "discrete" points. Do something like this:
plot(Time, Value, 'b.')
T
T 2012년 10월 16일
편집: T 2012년 10월 16일
Actually stairs(Time,Value) gave me what I wanted.
Can you respond to my other thread?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

질문:

T
T
2012년 10월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by