How to plot consistent data?
조회 수: 2 (최근 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
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.
채택된 답변
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
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개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!