フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I create a structure?

1 回表示 (過去 30 日間)
Amit Bhasin
Amit Bhasin 2019 年 1 月 24 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hello all,
I am trying to create a structure in which I want to store some information. For eg, I found number of columns and rows of an RGB image but whenever I am storing it in a structure its just giving me the name of that particular file not the actual value. Below is the code I used:
imRGB=imread('filename.jpeg');
Columns=size(imRGB,1)
P(2).Columns='Columns'
Rows=size(imRGB,2)
P(3).Rows='Rows'
  1 件のコメント
Stephen23
Stephen23 2019 年 1 月 24 日
編集済み: Stephen23 2019 年 1 月 24 日
Note that this is incorrect:
Columns=size(imRGB,1)
The first dimension of all arrays are the rows.
As well as that, note that you are creating a non-scalar structure. The unallocated fields of all elements of that structure will simply contain empty arrays, i.e.:
P(1).Columns
P(1).Rows
P(2).Rows
P(3).Columns

回答 (2 件)

Kevin Phung
Kevin Phung 2019 年 1 月 24 日
編集済み: Kevin Phung 2019 年 1 月 24 日
Remove the quotation marks. You're storing the string 'Columns' and 'Rows' isntead of the actual numeric variable.
You also dont need the indexing for your structure P.
P.Columns = Columns;
P.Rows = Rows;
should suffice

Amit Bhasin
Amit Bhasin 2019 年 1 月 24 日
Thanks it worked! However, I am little confused about the indexing! Can you please explain it?

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by