I am a newbie for Matlab. I try to take every two consecutive elements' means and put it between these two consecutive elements. For example; If I have a vector like below:
a=[1 2 5 4 3 6]
At the end I need b like:
b=[1 1.5 2 3.5 5 4.5 4 3.5 3 4.5 6]
It can be done via loops but I try to do via matlab function is it possible to do ?
The "brute force way":
b = zeros( 1, 2*numel(a)-1 );
b(1:2:end) = a; % take care of the original values
b(2:2:end) = 0.5*( a(1:end-1) + a(2:end) ); % the mean
Using interp1
:
b = interp1( 1:2:(2*numel(a)-1), a, 1:(2*numel(a)-1), 'linear' )
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다