フィルターのクリア

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 Center および File Exchange2-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