How to plot consistent data?

1 次查看(过去 30 天)
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 个评论
Jan
Jan 2012-7-10
编辑:Jan 2012-7-10
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 2012-7-10
编辑:Luffy 2012-7-10
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 ???

请先登录,再进行评论。

采纳的回答

Andrei Bobrov
Andrei Bobrov 2012-7-10
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 个评论
Joe Abraham
Joe Abraham 2012-7-16
Thanks for the help. But I got this error while executing.
??? Error using ==> strfind Input strings must have one row.
Andrei Bobrov
Andrei Bobrov 2012-7-16
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));

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by