convert plot(x,y) to plot(y(ind))

3 ビュー (過去 30 日間)
Muhannad
Muhannad 2015 年 6 月 24 日
コメント済み: Muhannad 2015 年 6 月 24 日
Hi,
I am trying to convert plot(x,y) to plot(y(ind)) So i am interesting in getting the indices of x which gives me y?
Thanks,

回答 (2 件)

Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 24 日
編集済み: Azzi Abdelmalek 2015 年 6 月 24 日
Just do this
plot(y)
  6 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2015 年 6 月 24 日
x = cumsum(hann(100));
y = linspace(-1,1,100);
plot(x,y);
idx=1:10:100
set(gca,'xtick',x(idx))
nxt=arrayfun(@num2str,idx,'un',0)
set(gca,'xticklabel',nxt)
Muhannad
Muhannad 2015 年 6 月 24 日
can you show the final results in plot(y(ind))? as I need the indices and not the plot.

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


Purushottama Rao
Purushottama Rao 2015 年 6 月 24 日
g=interp1(y,x,0.5)
g gives you the x value corresponding to the given y value (0.5).
Use a for loop to find out the entire range.
Hope this is what you are looking for
  3 件のコメント
Purushottama Rao
Purushottama Rao 2015 年 6 月 24 日
編集済み: Purushottama Rao 2015 年 6 月 24 日
x = cumsum(hann(100));
y = linspace(-1,1,100);
plot(x,y);
for k=1:length(y)
g(k)=interp1(y,x,y(k));
end
The speed looks to be ok. Ofcourse i do not know whether you are using the same x and y or not.
Muhannad
Muhannad 2015 年 6 月 24 日
so can you include another plot(y(ind)) which will give me the same shape as plot(x,y) but the x axis will be different and it will include the indices?

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

カテゴリ

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

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by