convert plot(x,y) to plot(y(ind))
1 次查看(过去 30 天)
显示 更早的评论
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,
0 个评论
回答(2 个)
Azzi Abdelmalek
2015-6-24
编辑:Azzi Abdelmalek
2015-6-24
Just do this
plot(y)
6 个评论
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)
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
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!