How to convert a row vector into a matrix ???

12 ビュー (過去 30 日間)
Sreeda M A
Sreeda M A 2016 年 6 月 29 日
コメント済み: Guillaume 2016 年 6 月 29 日
Using this code : C=reshape(C,[10,10]); I am getting an error like this : Error using reshape To RESHAPE the number of elements must not change.
Error in content (line 48) C=reshape(C,[10,10]); Please help me....

採用された回答

KSSV
KSSV 2016 年 6 月 29 日
編集済み: KSSV 2016 年 6 月 29 日
If you use reshape.... C=reshape(C,[10,10]); The matrix C (row vector) must have 10*10 = 100 elements. Does your C have 100 elements? You can convert a array into matrix of order [m,n] provided m*n = numel(C) i.e the m*n should be equal to the number of elements in C.
Eg.
C = rand(100,1) ;
C = reshape(C,[10,10]) ;
  1 件のコメント
Guillaume
Guillaume 2016 年 6 月 29 日
Note that you can leave the number of rows or columns blank if you know for example that you want 10 columns but don't want to calculate how many rows that will take:
C = reshape(C, [], 10); %use 10 columns and as many rows as necessary
The number of elements in the matrix still needs to be a multiple of 10 for it to work.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by