How to plot non equally spaced data in an equally spaced fashion and lable Xaxis with the data
1 次查看(过去 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:
0 个评论
回答(1 个)
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!