필터 지우기
필터 지우기

Lay one vector onto another

조회 수: 2 (최근 30일)
Joschua Kraus
Joschua Kraus 2018년 5월 11일
댓글: Joschua Kraus 2018년 5월 11일
Say you had two row vector:
filter = [0 0 0 0 0 0 0 0 0 0 ];
values = [1 2 1];
And the goal is to "lay the vector values onto the vector filter" like this:
new_filter = [0 0 1 2 1 0 0 0 0 0];
Here being done onward from index 3, or any other index.
How would that work?
  댓글 수: 2
Stephen23
Stephen23 2018년 5월 11일
"Here being done onward from index 3, or any other index. How would that work?"
You said it yourself: using indexing. What have you tried so far?
Joschua Kraus
Joschua Kraus 2018년 5월 11일
This works:
filter + [zeros(1,index-1) vals zeros(1,length(filter)-(index-1)-length(vals))]
thought there might be a build-in function

댓글을 달려면 로그인하십시오.

답변 (1개)

Cathal Cunningham
Cathal Cunningham 2018년 5월 11일
One method would be a for loop
filter = [0 0 0 0 0 0 0 0 0 0 ];
values = [1 2 1];
startIdx = 3;
for i = startIdx:length(filter)-startIdx+1
new_filter = filter;
new_filter(i:i+length(values)-1) = values
end
Or you could try circshift
filter = [0 0 0 0 0 0 0 0 0 0];
values = [1 2 1];
startIdx = 3;
new_filter = filter;
new_filter(startIdx:startIdx+length(values)-1) = values
for i = 1:length(filter)
new_filter = circshift(new_filter,1)
end

카테고리

Help CenterFile Exchange에서 Matched Filter and Ambiguity Function에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by