how to create incrementing arrays from each row of a matrix?

조회 수: 3 (최근 30일)
Javier Cabello
Javier Cabello 2020년 6월 2일
댓글: Javier Cabello 2020년 6월 3일
I have a big table starts like this
A B
33 17
30 -4
26 14
25 14
I would like to get a new array containing the increments of the form (B:A) from each of the rows.
For instance (table.B(1):table.A(1)), (table.B(2):tableA(2)) and so on.
Is there a simple way to do this? Is a loop necessary?
Thank you

채택된 답변

madhan ravi
madhan ravi 2020년 6월 2일
편집: madhan ravi 2020년 6월 2일
indices = arrayfun(@(x) Table.B(x):Table.A(x),1:size(B,1),'un',0);
  댓글 수: 2
madhan ravi
madhan ravi 2020년 6월 2일
Note: Don’t name a variable named table you will shadow the inbuilt function table(...)
Javier Cabello
Javier Cabello 2020년 6월 3일
Awesome! thanks for your help. Also thanks for noting the conflict with the function table, I just used it as a name here for my example.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by