How change only second number in a=ones(1,10)?

조회 수: 1 (최근 30일)
Bajdar Nouredine
Bajdar Nouredine 2024년 1월 16일
답변: Jaime Abad Arredondo 2024년 1월 16일

채택된 답변

Dyuman Joshi
Dyuman Joshi 2024년 1월 16일
Simply use indexing to change the element -
a = ones(1,10);
a(2) = 2
a = 1×10
1 2 1 1 1 1 1 1 1 1

추가 답변 (1개)

Jaime Abad Arredondo
Jaime Abad Arredondo 2024년 1월 16일
You should look at the syntax for array slicing. In matlab it's fairly easy. You would do something like:
a=ones(1,10);
disp(a)
1 1 1 1 1 1 1 1 1 1
a(2)=2;
disp(a)
1 2 1 1 1 1 1 1 1 1
Cheers!

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by