フィルターのクリア

Fix the trace in the plot

4 ビュー (過去 30 日間)
sally_wu
sally_wu 2016 年 2 月 6 日
コメント済み: Star Strider 2016 年 2 月 7 日
Is there a way somehow to get rid off the cross-line in this traces? For some reason,I am getting this cross-line that I do not want to! Any suggestions? Thanks
  1 件のコメント
Stephen23
Stephen23 2016 年 2 月 6 日
編集済み: Stephen23 2016 年 2 月 6 日
We need to see your data. Please upload it: click the paperclip button, then both the Choose file and Attach file buttons.

サインインしてコメントする。

回答 (3 件)

Star Strider
Star Strider 2016 年 2 月 6 日
Without your data, it’s difficult to say. One way would be to delete the last element of each of your x and y vectors:
x = [1:10 1];
y = randi(9, 1, 10);
y = [y y(1)];
figure(1)
subplot(2,1,1)
plot(x, y) % Original Data
subplot(2,1,2)
plot(x(1:end-1), y(1:end-1)) % Delete Wrap-Around
Run this little code snippet to see the cause and effect of the change.
  4 件のコメント
sally_wu
sally_wu 2016 年 2 月 6 日
編集済み: sally_wu 2016 年 2 月 6 日
ref=81;
slice=500;
A1 = loaddata('a2.txt');
d =size(A1);
j=0;
for i=1:d(1,1);
if(A1(i,1)==slice);
j=j+1;
a(j,1)=A1(i,2);
b(j,1)=A1(i,4)-ref;
end
plot(a(1:end-1), b(1:end-1))
grid on
end
My apologies, but it did not work out...I am still getting that annoying cross-line, which I do not want to..
Star Strider
Star Strider 2016 年 2 月 7 日
Please upload your data, preferably as a .mat file. Without having it to work with, I can only guess as to what the problem is (and thus far, that doesn’t seem to be productive for either of us).
Use the ‘paperclip’ icon to upload it, and then complete both the ‘Choose file’ and ‘Attach file’ steps.

サインインしてコメントする。


Azzi Abdelmalek
Azzi Abdelmalek 2016 年 2 月 6 日
Get ride of the last point in your plot

Geoff Hayes
Geoff Hayes 2016 年 2 月 6 日
sally - I suspect that if you are plotting something similar to
plot(x,y)
then some of your x values are out of order (i.e. 5000,5001,6799,6800,5002,5003,etc). For example, if I want to plot the curve
y = x^2;
where x is defined as
x = linspace(-25,25,1000);
which I then re-arrange (or sort out of order) the x values as
x = [x(251:end) x(1:250)];
I will observe the following upon plotting
y = x.^2;
plot(x,y)
I get the same "cross-line" as you! To correct, you can try to sort the x and y values as
data = sortrows([x' y']); % sort on first column
x = data(:,1);
y = data(:,2);
plot(x,y);
which should plot as expected without the undesirable line.

カテゴリ

Help Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by