필터 지우기
필터 지우기

How to insert a row into a matrix? How to insert one element in a spot a matrix?

조회 수: 7 (최근 30일)
I have a matrix of zeros
Z = zeros(11,20);
And I want to insert X into the first row:
X = [0 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18]
And Y in the first column:
Y = [0; 0;1;2;3;4;5;6;7;8;9]
As well, how do I insert an element into a specific position of the Z matrix?
Say I want to put a predetermined value of Distance = 20 into the spot (6, 4) ( row 6, column 4) of matrix Z.
Thank you!

채택된 답변

meghannmarie
meghannmarie 2019년 7월 25일
Z(1,:) = X;
Z(:,1) = Y;
Z(6,4) = 20;

추가 답변 (0개)

카테고리

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