필터 지우기
필터 지우기

How to convert 50x1 double to 1x100 double?

조회 수: 2 (최근 30일)
Nazmi Rosly
Nazmi Rosly 2022년 12월 12일
댓글: Davide Masiello 2022년 12월 12일
I want to convert 50x1 double to 1x100 double
  댓글 수: 1
Davide Masiello
Davide Masiello 2022년 12월 12일
What are the extra 50 elements in the 1x100 array?

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

답변 (1개)

Steven Lord
Steven Lord 2022년 12월 12일
How do you want the additional 50 elements to be created?
Or to give a smaller example, take y.
y = (1:5).^2
y = 1×5
1 4 9 16 25
If we wanted to create a vector x from y and have x contain 10 elements, how do you want to generate those elements?
Duplicating those elements?
x1 = repmat(y, 1, 2)
x1 = 1×10
1 4 9 16 25 1 4 9 16 25
x2 = repelem(y, 2)
x2 = 1×10
1 1 4 4 9 9 16 16 25 25
Pad with some placeholder values?
x3 = [y, zeros(1, 5)]
x3 = 1×10
1 4 9 16 25 0 0 0 0 0
x4 = [NaN(1, 5), y]
x4 = 1×10
NaN NaN NaN NaN NaN 1 4 9 16 25
Interpolation & extrapolation?
x5 = interp1(y, 1:0.5:5.5, 'linear', 'extrap')
x5 = 1×10
1.0000 2.5000 4.0000 6.5000 9.0000 12.5000 16.0000 20.5000 25.0000 29.5000
x6 = interp1(y, 1:0.5:5.5, 'spline', 'extrap')
x6 = 1×10
1.0000 2.2500 4.0000 6.2500 9.0000 12.2500 16.0000 20.2500 25.0000 30.2500
Or some other method?

카테고리

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

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by