フィルターのクリア

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 Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by