필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

replace the 2nd and 3rd elements without the use of find

조회 수: 2 (최근 30일)
Chaoyang Jiang
Chaoyang Jiang 2018년 6월 9일
마감: MATLAB Answer Bot 2021년 8월 20일
a=[2 3 4 1 3];
b=[1 1 0 1 0];
c=[2 3];
how to replace the 2nd and 3rd elements (c) in a(b) by 3 without the use of find? The expecting results are:
a(b)=[2 3 1];
a(b)(c)=[3 1];
The following code cannot run.
a(b)(c)=3;

답변 (1개)

James Tursa
James Tursa 2018년 6월 9일
Hints:
1) Create a new variable to store a(b) <-- Assuming b is a logical vector here!
2) Use c to index into this variable and replace the values
3) Assign this result back into a(b)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by