필터 지우기
필터 지우기

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
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)

카테고리

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