How to arrange a column vector into two columns?

조회 수: 9 (최근 30일)
Heirleking
Heirleking 2022년 2월 4일
편집: Heirleking 2022년 2월 4일
So, I have this vector and I need to arrange it as loops. Each value for each loop should start as the next integer from the previous ending loop x= [128 147 166 181 195 216 236 255]
It should look something like this x= [128 147; 148 166; 167 181; 182 195; 196 216; 217 236; 237 255]
I cannot do it manually, since I have to arrange several vectors that will not have the same length as this one. I tried using nested for loops but wasn't successful
  댓글 수: 4
Stephen23
Stephen23 2022년 2월 4일
"May be becuase, it falls in the intervel [217 255]."
Every (non-end) element in that vector falls in the interval formed by its adjacent elements. What is so special about 236?
Heirleking
Heirleking 2022년 2월 4일
You are right, I corrected the mistake

댓글을 달려면 로그인하십시오.

채택된 답변

Stephen23
Stephen23 2022년 2월 4일
편집: Stephen23 2022년 2월 4일
Assuming that the missing 236/237 row is a mistake:
x = [128,147,166,181,195,216,236,255]
x = 1×8
128 147 166 181 195 216 236 255
m = [x(1),1+x(2:end-1);x(2:end)].'
m = 7×2
128 147 148 166 167 181 182 195 196 216 217 236 237 255

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by