How to replace the 5 in my vector with decreasing numbers like 5,4,3,2,1

1 次查看(过去 30 天)
x(3:4,3:5) = 5
  3 个评论
Pallav Patel
Pallav Patel 2020-2-24
Try the command in Matlab and you will see the columns and rows specified will be filled with 5's. Matlab automatically fills an undefined vector with zeros. what I am trying to do is have a decreasing or increasing number and that was just a template to upload to Mathworks. I have seen such an example before but can't seem to find it.

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2020-2-24
x(3:4,3:5) = reshape(5:-1:0, 2, 3);

更多回答(1 个)

madhan ravi
madhan ravi 2020-2-23
Z=num2cell(x);
Z(cellfun(@(zx)zx==5,Z))={5:-1:1}
celldisp(Z)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by