How do I fix my graph?
7 ビュー (過去 30 日間)
古いコメントを表示
I have a script which creates a few graphs based on calculations carried out. The graph looks very strange however. Once the graph finishes, it appears to go back to the start, so to speak. What can I do to stop this from happening? For example, I want the graph below to stop at ~(260,0) and not go back to ~(0,-900).
2 件のコメント
Bob Thompson
2018 年 11 月 29 日
What is causing your dataset to generate the last value?
It would always be an option to simply leave off the last value from the range you are entering as your data set, but this is not a good option as you might lose track of valuable information.
回答 (1 件)
Mark Sherstan
2018 年 11 月 30 日
編集済み: Mark Sherstan
2018 年 11 月 30 日
Try the code below. Esentially I find the first instence when a value is greater than 260 and eliminate from that point to the end in both x and y vectors. You have to be careful with this as you could eliminate some data without meaning to so just make sure you are confident of your cutoff time (e.g. 260 in this case).
x = [0 100 150 200 250 300 0];
y = [0 500 1000 -500 -900 -300 -900];
figure(1); plot(x,y)
idx = find(x>260);
x(idx(1):end) = [];
y(idx(1):end) = [];
figure(2); plot(x,y)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!