フィルターのクリア

How do I change a variable in my workspace?

2 ビュー (過去 30 日間)
Jewel
Jewel 2018 年 7 月 10 日
コメント済み: Jewel 2018 年 7 月 10 日
I am trying to change a matrix located in my workspace. It is originally a 1 x 48 matrix and I am just wondering how to edit the dimensions of the matrix. Thank you!
Attached below is my code:
data = textscan(fileID, '%f%f%f%f%f%f','HeaderLines',6,'CollectOutput','');
fclose(fileID);
X = data{1};

採用された回答

James Tursa
James Tursa 2018 年 7 月 10 日
編集済み: James Tursa 2018 年 7 月 10 日
doc reshape
E.g.,
X = your 1x48 vector
Y = reshape(X,4,12); % <-- reshaped to a 4x12 matrix
Z = Y(:); % <-- reshaped to a column vector
  1 件のコメント
Jewel
Jewel 2018 年 7 月 10 日
Thank you!

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2018 年 7 月 10 日
If you want to change the shape of the array without changing the number of elements, take a look at the reshape function.
If you want to change the number of elements in the array, you'll probably want to use the repmat or repelem functions or the operations of indexing or concatenation.
  1 件のコメント
Jewel
Jewel 2018 年 7 月 10 日
Thank you!

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

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by