Assign Values into a matrix (DG)

1 回表示 (過去 30 日間)
DARAN GRIFFITHS
DARAN GRIFFITHS 2020 年 11 月 15 日
回答済み: madhan ravi 2020 年 11 月 15 日
hi
i'm a total novice to Matlab, i'm trying to assign individual values to elements in a Matrix,
EG
A 5x5 matrix
50 50 50 50 50 - Constant Value
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0 - Constant Value
For 1st column and last column values should be decreasing to 0?
i.e
50 50 50 50 50 - Constant Value
37.5 0 0 0 37.5
25 0 0 0 25
12.5 0 0 0 12.5
0 0 0 0 0 - Constant Value
i would like to be able to do this for any iinputted size matrix, with constants always being teh same?
thanks

回答 (1 件)

madhan ravi
madhan ravi 2020 年 11 月 15 日
matrix(:, 1) = linspace(matrix(1, 1), 0, size(matrix, 1));
matrix(:, end) = linspace(matrix(1, end), 0, size(matrix, 1))

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by