x1 = 0:.01:4;
x2 = 0:.03:5;
x3 = 0:.02:6;
y1 = sin(3*pi*x1);
y2 = sin(3*pi*x2);
y3 = sin(3*pi*x3);
figure,plot(x1,y1,'o',x2,y2,'s',x3,y3,'x')
p(1)=pchip(x1,y1);
p(2)=pchip(x2,y2);
p(3)=pchip(x3,y3);
time = min([x1 x2 x3]):...
min([diff(x1) diff(x2) diff(x3)]):...
max([x1 x2 x3]);
for ind = 1:3
output(ind,:)=ppval(p(ind),time);
end
output(1,find(time>max(x1)))=nan;
output(2,find(time>max(x2)))=nan;
output(3,find(time>max(x3)))=nan;
hold on
plot(time,output',time,nanmean(output),'--')
legend('data1','data2','data3',...
'interp1','interp2','interp3',...
'average sig')
1 Comment
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/337705-how-to-average-plots-that-differ-in-x-and-y-data#comment_449483
Direct link to this comment
https://ch.mathworks.com/matlabcentral/answers/337705-how-to-average-plots-that-differ-in-x-and-y-data#comment_449483
Sign in to comment.