# how can fix this problem with matrix ?

4 ビュー (過去 30 日間)
Mira le 2019 年 10 月 28 日
コメント済み: Adam Danz 2019 年 10 月 30 日
How can I create matrix with the size N,m?
How can I copy each array of matrix in a vector and make the modification in it
and the replace again in the matrix?
Example
vector = M (1,:)
after modification of the vector
M(1,:) = vector
But an error appear " Index exceeds matrix dimensions."

#### 4 件のコメント

Adam Danz 2019 年 10 月 28 日
"But an error appear " Index exceeds matrix dimensions.""
If you intend to modify a single column of a matrix, you cannot change the number of rows. You can replace some of the existing values with NaN or missing but it must maintain its shape and size if it remains as part of the matrix.
Mira le 2019 年 10 月 30 日
the size of matrix M is N = 10 and m = 4
M = 1 2 0 3
0 0 3 5
6 4 2 0
.
.
N
vector = M(1,:)
vector = 1 2 0 3
appear the error
Adam Danz 2019 年 10 月 30 日
vector = M (1,:)
% Somewhere between these two lines your vector is changing in one
% of the following 2 ways:
% 1) it's length is changing
% 2) it is converted to a column vector instead of a row vector
% 3) an additional row is added to the vector making it a matrix
M(1,:) = vector

サインイン to comment.

### 回答 (1 件)

Sai Bhargav Avula 2019 年 10 月 30 日
Hi, May be after modification you vector became a column vector. Try
M(1,:) = vector';
If this doesn't work, provide the value of size(vector).
Hope this helps!

#### 0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

R2017a

Translated by