How to make columns the same size

조회 수: 5 (최근 30일)
Matheus Brito
Matheus Brito 2020년 2월 21일
답변: Jos (10584) 2020년 2월 21일
My data has two columns (A and B). Column A has a number of rows. Column B has fewer rows than A. How can I make column B have the same number of rows as A ? also, These rows must be filled with the average of the row data in column A.

채택된 답변

Jos (10584)
Jos (10584) 2020년 2월 21일
A solution:
A = [1 3 ; 2 4 ; 5 7]
B = [10 11 12 ; 13 14 15]
newB = repmat(mean(A,2), 1, size(B,2))
newB(1:size(B,1),:) = B

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by