How do we shift the cell of a variable and replace it by NaN?
조회 수: 3 (최근 30일)
이전 댓글 표시
I have a variable x. The x contains a large number of values. When I open x in the workspace, I see the first value is in the 1st cell, second value is in the second cell and so on. I want to shift the the values from celll 1 to cell 5 and replace the first five cells with NaN. How will we do this?
For example, x = 20, 30, 40, 50, 60
I want to shift these values, therefore my new x after shifting will be NaN NaN NaN NaN NaN 20, 30, 40, 50, 60
Any help will really be appreciated.
Thanks.
댓글 수: 0
채택된 답변
DGM
2022년 1월 25일
It depends what you mean by "shift". Consider the two examples:
x = 20:20:200
a = [NaN(1,5) x] % simply concatenate
b = [NaN(1,5) x(1:end-5)] % shift right and fill with NaN
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!