Matlab插值切换因变量
我有一个Nx2矩阵,列为“时间”和“进度” 进度是整数,时间是对应于每个进度单位的实际值 我想反转依赖关系,使“时间”成为整数,并在每个单位时间步输出分数“进度” 如何做到这一点?使用Matlab插值切换因变量,matlab,interpolation,Matlab,Interpolation,我有一个Nx2矩阵,列为“时间”和“进度” 进度是整数,时间是对应于每个进度单位的实际值 我想反转依赖关系,使“时间”成为整数,并在每个单位时间步输出分数“进度” 如何做到这一点?使用interp1(进度、时间、所需时间)其中所需时间是一个包含所需时间的新向量。例如: Progress=1:10; %just a guess of the sort of progress you might have Time=Progress*5.5; %the resulting times
interp1(进度、时间、所需时间)
其中所需时间是一个包含所需时间的新向量。例如:
Progress=1:10; %just a guess of the sort of progress you might have
Time=Progress*5.5; %the resulting times (say 5.5s per step)
TimesWanted=10:5:50; %the times we want
interp1(Time,Progress,TimesWanted)
给我:
ans =
1.8182 2.7273 3.6364 4.5455 5.4545 6.3636 7.2727 8.1818 9.0909
这是通过插值获得的所需时间的进度。使用interp1(进度、时间、所需时间)
其中所需时间
是包含所需时间的新向量。例如:
Progress=1:10; %just a guess of the sort of progress you might have
Time=Progress*5.5; %the resulting times (say 5.5s per step)
TimesWanted=10:5:50; %the times we want
interp1(Time,Progress,TimesWanted)
给我:
ans =
1.8182 2.7273 3.6364 4.5455 5.4545 6.3636 7.2727 8.1818 9.0909
这是通过插值获得的所需时间的进度