필터 지우기
필터 지우기

How to plot consistent data?

조회 수: 2 (최근 30일)
Joe Abraham
Joe Abraham 2012년 7월 10일
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에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by