Replace numbers in a matrix

1 回表示 (過去 30 日間)
Micheal McDonagh
Micheal McDonagh 2021 年 6 月 16 日
回答済み: Cris LaPierre 2021 年 6 月 16 日
Here is my code below. I have created a randon 2*x4 matrix. I have replace the first row with 1:4. and the third colume with 10:11. so my question is how do i replace the 4th colume with 2 and 5? or something like 9 and 8, without using the colon operator..
mat = randi([1,10],2,4)
mat(1,:) = 1:4
mat(:,3) = 10:11

採用された回答

Cris LaPierre
Cris LaPierre 2021 年 6 月 16 日
Create your vector of numbers using square brackets, and assign it to column 4 the same way you did for the 3rd column.
Hint: 10:11 is the same as [10 11]
See Chs 4 and 5 of MATLAB Onramp.

その他の回答 (0 件)

カテゴリ

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