Plot a line over spectrogram

조회 수: 11 (최근 30일)
Pegah Hosseini
Pegah Hosseini 2013년 7월 18일
댓글: Pegah Hosseini 2014년 1월 6일
I use the following code to plot a line over my spectrogram so that I show the onset time. But it sometimes plots the line over the spectrogram and sometimes the spectrogram over the line (the line is there from y=0 to y=10 then not there from y=10 to y=20 and then again it is there from y=20 to y=30). Any suggestions?
figure surf(x,y,z,'edgecolor','none'); axis tight; view(0,90); colorbar set(gca,'fontsize',14) hold on h=line([0 0],[y(1) y(end)],'color','m','Linestyle','-','LineWidth',2); uistack(h,'top')
I also tried:
h=get(gca,'Children'); set(gca,'Children',h(end:-1:1))
or
set(gca,'Children',h(1:end))
but no luck. All tries give exactly the same result.

채택된 답변

Jeremy
Jeremy 2014년 1월 6일
I've done this before, I believe the trick is to set the Z-value for your line so that is always above the spectrogram.
  댓글 수: 1
Pegah Hosseini
Pegah Hosseini 2014년 1월 6일
Although this question goes back to July, I am still happy to learn something new. Thanks alot for your help. It works perfectly. Example:
X=-2:10;Y=-2:10;Z=randn(13,13)*2;
surf(X,Y,Z,'edgecolor','none');
axis tight;
view(0,90);
hold on
zm=max(max(Z));
zmm=repmat(zm,1,length(Y(1):Y(end)));
h=plot3(zeros(1,length(zmm)),Y(1):Y(end),zmm,'-m','LineWidth',2);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by