在我看來,這是你想要的東西:
x=[0.125 0.250 0.375 0.500 0.625 0.750 0.875 1.000 1.125 1.250]
y=[4.1 4.6 4.3 4.4 4.8 4.6 4.3 4.9 4.1 4.2]
xx = x(y > 4.5 | [0, (arrayfun(@(n) (y(n-1) > 4.5 & y(n+1) ...
> 4.5 & y(n) <= 4.5), 2:length(y)-1)), 0])
yy = y(y > 4.5 | [0, (arrayfun(@(n) (y(n-1) > 4.5 & y(n+1) ...
> 4.5 & y(n) <= 4.5), 2:length(y)-1)), 0])
xx =
0.25000 0.62500 0.75000 0.87500 1.00000
yy =
4.6000 4.8000 4.6000 4.3000 4.9000
更新:從意見有了新的樣本數據:
y = [4.9 3 4.6 4.1 4.7 4.1 4.2 4.6 4.3 4.9];
yy =
4.9000 3.0000 4.6000 4.1000 4.7000 4.6000 4.3000 4.9000
It 可能也是要:
xx = x((y > 4.5 & [1, (arrayfun(@(n) (y(n-1) > 4.5 | y(n+1) ...
> 4.5), 2:length(y)-1)), 1]) | [0, (arrayfun(@(n) (y(n-1) > 4.5 & y(n+1) ...
> 4.5 & y(n) <= 4.5), 2:length(y)-1)), 0])
yy = y((y > 4.5 & [1, (arrayfun(@(n) (y(n-1) > 4.5 | y(n+1) ...
> 4.5), 2:length(y)-1)), 1]) | [0, (arrayfun(@(n) (y(n-1) > 4.5 & y(n+1) ...
> 4.5 & y(n) <= 4.5), 2:length(y)-1)), 0])
xx =
0.62500 0.75000 0.87500
yy =
4.8000 4.6000 4.3000
當你的y數據是:[4.9 3 4.6 4.1 4.7 4.1 4.2 4.6 4.3 4.9 ...]'會發生什麼?這會導致:'[4.9 4.6 4.7 4.6 4.9 ...]'? –
是的,這是最好的方式,我沒有意識到可能發生! – user3683409