Struct contents reference from a non-struct array object.

folder='D:\CO2hydrate\bubleexp\New folder (3)';
filename = fullfile(folder,'.*tiff');
n=length(filename);
imag1=imread(fullfile('New folder (3)',filename(1).name));
imag2=imread(fullfile('New folder (3)',filename(2).name));
Sumimage=imag_1+imag_2;
figure(1);
imshow(Sumimage);
error:
Struct contents reference from a non-struct array object.
Error in Untitled2 (line 4)
imag1=imread(fullfile('New folder (3)',filename(1).name));

1 件のコメント

Ashok Kumar
Ashok Kumar 2021 年 2 月 24 日
Struct contents reference from a non-struct array object. What is this error and how to resolve it.

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

回答 (2 件)

Fangjun Jiang
Fangjun Jiang 2021 年 2 月 24 日

1 投票

In your code, variable "filename" is a string. It does not have the structure field ".name".
If your code looks like this, then you can use filename(1).name
filename=dir('*.tiff')
Shu-Wei Hsu
Shu-Wei Hsu 2021 年 2 月 24 日

1 投票

Please find the detailed documentation for function "fullfile".
"fullfile" returns full file name from input argument.
In your case, you need to use "dir" to find all the interested files.
Please find the detailed documentation here.

カテゴリ

ヘルプ センター および File ExchangeFunctions についてさらに検索

質問済み:

2021 年 2 月 24 日

回答済み:

2021 年 2 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by