How to plot consistent data?

2 views (last 30 days)
Joe Abraham
Joe Abraham on 10 Jul 2012
Hi,
I am new to matlab. I have 2 variables T and H with 1652 cells in each. I want to plot H vs T when T is consecutively increasing for 10 values.
for eg :
let T = [9 8 7 8 9 7 6 5 4 5 6 7 8 9 10 11 12 13]
H= 1:18
i want to plot H vs T for the last 10 values of T
ie, T= [4 5 6 7 8 9 10 11 12 13]
H=[9 10 11 12 13 14 15 16 17 18]
Thanks once again !!
[EDITED, Jan] Information required to define the question exactly belongs to the question. It is not a minor comment.
THe logic i tried was:
for i= 1:length(H)-11
for k=1:10
if T(i)>T(i+k)
T(i)=NaN
T(i+k)=NaN
H(i)=NaN
H(i+k)=NaN
end
end
end
plot(T,H)
But I am not getting desired results. Any advice to improve this logic would be helpful
Thanks
  2 Comments
Jan
Jan on 10 Jul 2012
Edited: Jan on 10 Jul 2012
Please read the instruction about code formatting again. It is worth to care about the forum rules and standard. If in doubt, follow the "About Matlan Answers" button or the "? Help" button, which appears, when you add a new message.
Using "matlab" as tag is meaningless in a Matlab forum, isn't it?
When I spend too much time with editing a question and merging comments, I'm not motivated to answer anymore. But here are enough other users, who will do this.
Luffy
Luffy on 10 Jul 2012
Edited: Luffy on 10 Jul 2012
What kind of results do you desire,your code seems to be generating vectors you've written on the top,is there a problem in graph ???

Sign in to comment.

Accepted Answer

Andrei Bobrov
Andrei Bobrov on 10 Jul 2012
T = [9 8 7 8 9 7 6 5 4 5 6 7 8 9 10 11 12 13];
a = [true,diff(T)>=0];
a(strfind(a,[0 1])) = true;
n = 10;
ii = find(conv(a+0,ones(1,n),'same') == n,n,'last') - n/2 + 1;
idx = ii:ii+n-1;
plot(T(idx),H(idx));
  2 Comments
Joe Abraham
Joe Abraham on 16 Jul 2012
Thanks for the help. But I got this error while executing.
??? Error using ==> strfind Input strings must have one row.
Andrei Bobrov
Andrei Bobrov on 16 Jul 2012
strfind only for row
eg
yourData = [9 8 7 8 9 7 6 5 4 5 6 7 8 9 10 11 12 13].';
T = yourData(:).';
a = [true,diff(T)>=0];
a(strfind(a,[0 1])) = true;
n = 10;
ii = find(conv(a+0,ones(1,n),'same') == n,n,'last') - n/2 + 1;
idx = ii:ii+n-1;
plot(T(idx),H(idx));

Sign in to comment.

More Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!