필터 지우기
필터 지우기

Storing arrays in a matrix

조회 수: 48 (최근 30일)
EDEN
EDEN 2019년 3월 29일
편집: Jan 2019년 3월 29일
Hello friends, i am a making a program that will generate this format of a number <i,j,k> meaning three distinict numbers each time. i want to store that numbers in a matrix. how can i do that. get three numbers from a loop and store them in a array and that 1X3 arrays should be stored in a matrix.
thank you.
  댓글 수: 2
madhan ravi
madhan ravi 2019년 3월 29일
Where is your code that you are trying to solve for your homework?
EDEN
EDEN 2019년 3월 29일
i havent started yet. i will get many arrays of 1X3 so i need to but those arrays in a matrix.
can u help me plz.

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

채택된 답변

Jan
Jan 2019년 3월 29일
편집: Jan 2019년 3월 29일
n = 100; % store 100 vectors
Result = zeros(n, 3); % reserve memory for n [1x3] vectors
for k = 1:100
v = rand(1, 3); % obtain the vector, your code comes here
Result(k, :) = v; % collect the vectors in a matrix
end
Please read the "Getting Started" chapter of the documentation and process Matlab's OnRamp to learn the basics: https://matlabacademy.mathworks.com/

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by