How to use linspace on a matrix

130 ビュー (過去 30 日間)
Maaz Madha
Maaz Madha 2021 年 4 月 17 日
コメント済み: Maaz Madha 2021 年 4 月 17 日
Dear all
I have these values on a matrix and would like it to decrease from 0.8112 to 0.6(for the first column) evenly across all the rows. I would really appreciate any help on how to do this

採用された回答

Jan
Jan 2021 年 4 月 17 日
A = [0.8112, 0.8861, 0.8112, 0.8861; ...
1, 1, 1, 1; ...
1, 1, 1, 1; ...
1, 1, 1, 1; ...
1, 1, 1, 1; ...
0.6, 0.6, 0.6, 0.6];
n = size(A, 1);
A(2:n-1, :) = A(1, :) + ((A(n, :) - A(1, :)) / (n - 1)) .* (1:n-2).'
  1 件のコメント
Maaz Madha
Maaz Madha 2021 年 4 月 17 日
thank you so much sir.

サインインしてコメントする。

その他の回答 (1 件)

David Hill
David Hill 2021 年 4 月 17 日
yourMatrix=repmat(linspace(.8112,.6,100)',1,13);

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by