HI i want of plot the beginning and end of an array, leaving out the middle bit
something like . . . (here the comma doesn't work)
figure, plot(x(1:417,900:1000), y(1:417,900:1000))
is there an easy way to do this without splitting up the array?
thanks
Charlie

 採用された回答

Adam
Adam 2017 年 1 月 6 日
編集済み: Adam 2017 年 1 月 6 日

0 投票

figure; plot(x([1:417,900:1000]), y([1:417,900:1000]))
You have to put your indices into an array, then you can use them as any other array of indices, irrespective of whether they are contiguous or not.

2 件のコメント

Steven Lord
Steven Lord 2017 年 1 月 6 日
In addition to what Adam said, if you want to leave a "gap" between elements 417 and 900, add a NaN value. As a simpler example:
% The NaN at the end of x allows us to put a NaN in the middle
% of the array to be plotted, x(ind), using indexing
x = [1:10 NaN];
y = x.^2;
ind = [1:5 11 7:10];
plot(x(ind), y(ind), 'o-')
Note that the points (5, 25) and (7, 49) are not connected. If instead you'd done something like:
ind2 = [1:5 7:10];
plot(x(ind2), y(ind2), 'o-')
those two points would be connected.
cgenes
cgenes 2017 年 1 月 7 日
ok thanks for this I don't want the point to be connected so i will try this

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeGraphics Objects についてさらに検索

タグ

質問済み:

2017 年 1 月 6 日

コメント済み:

2017 年 1 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by