필터 지우기
필터 지우기

How to plot non equally spaced data in an equally spaced fashion and lable Xaxis with the data

조회 수: 4 (최근 30일)
Hi all,
I am trying to plot three variable on the double Y axis, I set "frequency" as X axis; "Tvalue" as left Y axis; "correlation" as right Y axis.I want to plot "correlation" as bar plot,Tvalue as line plot.
figure(1)
[hAxes,hBar,hLine]=plotyy(freq,T,freq,correlation,'bar','plot');%%
set(hLine,'color',[0,0,1],'LineWidth',1,'Marker','o','MarkerSize',2,...
'MarkerFace','y')
set(hAxes(1),'ylim',[-3 6])
set(hAxes(2),'ylim',[0 0.5])
set(hAxes(1),'yTick',[-3:1:6]);
set(hAxes(2),'yTick',[0:0.1:0.5]);
set(gca,'XTick',[0:0.05:1]);
xlabel('Frequency')
ylabel(hAxes(1),'Tvalue')
ylabel(hAxes(2),'correlation')
The problem I am facing is that I cannot plot the data in an equally-spaced plot . This is what I have now:

답변 (1개)

KSSV
KSSV 2020년 12월 3일
Read about interp1. USe interpolation and make the data even. Let F, T be your column data.
m = length(F) ;
Fi = linspace(min(F),max(F),m) ;
Ti = interp1(F,T,Fi) ;
plot(Fi,Ti)
  댓글 수: 5
楠 赵
楠 赵 2020년 12월 4일
Sorry, I still cannot figur out how to use xticks to present data from"freq".
freq=1./(period/10);
freq=freq(1,29:108);
freq_l = 1:length(freq);
figure(2)
Ti = T(numch,:);
Ci = coher_mt(numch,:);
%Fi = linspace(min(freq),max(freq),m) ;
%Ti = interp1(freq,T(numch,:),Fi) ;
%Ci = interp1(freq,coher_mt(numch,:),Fi) ;
[hAxes,hLine1,hLine2]=plotyy(freq_l,Ti,freq_l,Ci,'plot','stem');%%
set(hLine2,'LineWidth',1,'Marker','o','MarkerSize',2,...
'MarkerFace','y')
set(hLine1,'LineWidth',1,'Marker','o','MarkerSize',2)
set(hAxes(1),'ylim',[-3 6],'yTick',[-3:1:6])
set(hAxes(2),'ylim',[0 0.5],'yTick',[0:0.1:0.5])
this is what I have now:

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

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by