Replacing element of a matrix

How to replace every n th element of matrix with some number
matrix has vertical shape
and is single row matrix

回答 (1 件)

Rik
Rik 2022 年 8 月 25 日

0 投票

I suspect this is homework, so I'm only going to give you a suggestion:
You should have a look at the colon operator and how you can assign values to an array with indexing.
2:4
ans = 1×3
2 3 4
A=rand(1,5);
A(4)=5
A = 1×5
0.2997 0.3387 0.0137 5.0000 0.4140

カテゴリ

ヘルプ センター および File ExchangeResizing and Reshaping Matrices についてさらに検索

質問済み:

2022 年 8 月 25 日

編集済み:

Rik
2022 年 8 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by