How to use linspace on a matrix
87 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Maaz Madha
am 17 Apr. 2021
Kommentiert: Maaz Madha
am 17 Apr. 2021
Dear all
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/586456/image.png)
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
0 Kommentare
Akzeptierte Antwort
Jan
am 17 Apr. 2021
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).'
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!