How to use linspace on a matrix

조회 수: 107 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by