フィルターのクリア

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

1 回表示 (過去 30 日間)
Pallav Patel
Pallav Patel 2020 年 2 月 23 日
回答済み: Walter Roberson 2020 年 2 月 24 日
x(3:4,3:5) = 5
  3 件のコメント
Walter Roberson
Walter Roberson 2020 年 2 月 24 日
This is not clear, as you do not appear to have a vector.
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)
  1 件のコメント
Pallav Patel
Pallav Patel 2020 年 2 月 24 日
Thank you Madhan. Is ther any way I can do it without the cell function.

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

カテゴリ

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

タグ

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by