필터 지우기
필터 지우기

Creating empty matrix with data in 1 cell

조회 수: 3 (최근 30일)
Ross Thompson
Ross Thompson 2022년 2월 14일
댓글: VBBV 2022년 2월 15일
I want to generate an empty MATRIX containing all zeros apart from 1 or 2 cells which i want to assign a value to. Currently im using M = zeros(1,100); which generates my empty matrix but im unsure how to then assign a value to one of those cells.

답변 (1개)

VBBV
VBBV 2022년 2월 14일
편집: VBBV 2022년 2월 14일
M = zeros(1,100);
M(1,2:3) = 5% say 5
assign value of 5 to elements 2 and 3 in array
  댓글 수: 3
Ross Thompson
Ross Thompson 2022년 2월 15일
How would this work if the elements wernt next bto each other in the MATRIX?
VBBV
VBBV 2022년 2월 15일
M = zeros(1,100);
M(1,[2:3 10 20 30]) = 5% say 5
Set value of 5 to elements 2,3 10, 20, and 30. By brackets []

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

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by