Arguments of Reshape function with example

8 ビュー (過去 30 日間)
Manu Chaudhary
Manu Chaudhary 2022 年 1 月 18 日
コメント済み: Manu Chaudhary 2022 年 1 月 18 日
Hi everyone. I am completely new to matlab and struggling with the syntax.
Suppose,
A = [1 2; 3 4; 5 6]
reshape(A, [1,6])
reshape(A, [1 6])
Both the reshape gives similar kind of result. I am confused with the syntax. Please explain me the syntax and working of reshape.
Suppose, if I put
reshape (A, [1 2]) then I will start getting errors.
Suppose I have a colored image of 64x64.

採用された回答

KSSV
KSSV 2022 年 1 月 18 日
A = [1 2; 3 4; 5 6] ;
% this is a 3*2 matrix
reshape(A, [1,6])
reshape(A, [1 6])
% Both the above commands are same. whether you put , in [1 6] or not mean the same.
reshape (A, [1 2]) % this will definetly throw error, becuase you can reshape 3*2 = 6 elements into 1*2 = 2 elements.
You have 64*64 colored image, what exactly you want to do with it?
  7 件のコメント
KSSV
KSSV 2022 年 1 月 18 日
input_image_3D = imread('./Images/Image_64x64.jpg'); % this reads an image
data= input_image_3D(:, : ,1); % this extracts first channel/ Red channel/ first matrix of mxnx3
In the above : means all, i.e. all the rows and all the columns. First position is rows and second position is columns.
data= reshape(testingReadFile1,[64 64 3])); % this reshapes an array into 64x64x3.
output = data(1:64, 1:64, 1:3); % this is nothing but saving array data into other array variable output
% the above can be simply written as
output = data ;
Manu Chaudhary
Manu Chaudhary 2022 年 1 月 18 日
Thank you Stephen and KSSV for sharing such great links and answering my all questions. I am highly thankful to you for your generous help and support.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by