Save part of an array

조회 수: 3 (최근 30일)
So
So 2016년 6월 15일
답변: Shameer Parmar 2016년 6월 15일
Hello, For example I have the matrix A = [1 2 3 4 5 6 7 8 9 10.....10000]. And I want to save in a matrix B(k) where B(1) = the first 20 elements of A so B(1) = [1...20], B(2) = [21...40], B(3) = [41...60] etc... Thank you :)

채택된 답변

Shameer Parmar
Shameer Parmar 2016년 6월 15일
Hello Sonarine,
Try for this..
A = [1:10000];
for i = 1:length(A)/20
B(i,:) = A((i-1)*20+1:i*20);
end
to check the output..
B(1,:)
B(2,:)
So on..

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 6월 15일
Use mat2cell()

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by