I have a row vector of dimension 1x300 and want to set its elements to zero without changing its dimension. I am trying to implement it using the example X = zeros(1,3,'uint32') provided in the documentation on zeros in mathworks.

조회 수: 1 (최근 30일)
Setting the row vector to zero is changing its dimension.
The example in the documentation X = zeros(1,3,'uint32') is giving the following error, 'Index in position 3 exceeds array bounds (must not exceed 1).'
How can it be solved?

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 11월 8일
This error probably happens because you have variable name 'zeros' in your workspace. Running the following line
clear zeros
or restarting MATLAB will solve the problem.

추가 답변 (1개)

Subhadeep Koley
Subhadeep Koley 2020년 11월 8일
Hi Sushma TV, the below code might help
% Define a random vector 'X' for example
X = rand(1, 300);
% Set all elements of 'X' to zero
X = zeros(size(X), 'uint32');

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by