Interpolation of two Matrices of different Lenght
1 次查看(过去 30 天)
显示 更早的评论
Hallo,
I am looking for a solution for my problem to "account" two Matrices of different Lengths.
I have two Sensors which have differnet Sampling Rates, so the Matrices with the Measurements have different lengths. Now I want to plot theses two Matrices in one Plot. The Problem is that in Matlab the Vetors must have the same Length to plot them together. I used the "downsample"-function to get the two Matrices to the same Length, but I don't like it because with this Method I loose many measured Values.
I would like to use a function like "interp1" (interp1 doesn't work either because of the different length of the matrices) so my programm doesn't skip any measured values.
Do you know a Matlab-function which can help me with my Problem? Thanks
回答(1 个)
José-Luis
2014-1-29
t1 = 1:20;
t2 = 1:2:20;
data1 = rand(numel(t1),1);
data2 = rand(numel(t2),1);
%One alternative
figure(1)
plot(t1,data1,t2,data2);
%Another
figure(2)
plot(interp1(t1,data1,t2),data2,'ro');
hold on
plot(get(gca,'Xlim'),get(gca,'XLim')); %1:1 line
%Yet another
figure(3)
plot(interp1(t2,data2,t1),data1,'ro');
hold on
plot(get(gca,'Xlim'),get(gca,'XLim')); %1:1 line
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!