How to replace an integer in a vector with another vector?

How can you replace a single element in a vector with a vector? I tried using logical indexing but it says "In an assignment A(I) = B, the number of elements in B and I must be the same." Kindly help.Thanks in advance.

 채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2015년 8월 7일
a=[1 2 3 4]
b=[10 20 30]
idx=find(a==2)
out=[a(1:idx-1) b a(idx+1:end)]

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품

태그

Community Treasure Hunt

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

Start Hunting!

Translated by