Dot indexing is not supported for variables of this type

18 ビュー (過去 30 日間)
Muhammad Armaghan Ur Rahman
Muhammad Armaghan Ur Rahman 2022 年 12 月 20 日
Diamond = strel('diamond', 6); Diamond.Neighborhood
Disk = strel('Disk', 7); Disk.Neighborhood
Octagon = strel('Octagon', 6); Octagon.Neighborhood
Square = strel('Square', 13); Square.Neighborhood
Rectangle = strel('Rectangle', [3 13]); Rectangle.Neighborhood
Line = strel('line', 13,0); Line.Neighborhood
images = {Diamond,Disk,Octagon,Square,Rectangle,Line};
titles = {'Diamond','Disk','Octagon','Square','Rectangle','Line'};
for ii=1:6
subplot(2,3,ii)
image(images(ii).Neighborhood); colormap(gray(2));
title(titles(ii),fs,18)
end
Given above is my code. I am getting this error Dot indexing is not supported for variables of this type for line image(images(ii).Neighborhood); colormap(gray(2));
I checked image(1) in the command window and got 1×1 cell array {1×1 strel} while I need the data in Diamond. I tried using cell2mat but it does not work (throws another error). Thanks in advance.

回答 (1 件)

Stephen23
Stephen23 2022 年 12 月 20 日
編集済み: Stephen23 2022 年 12 月 20 日
IMAGES is a cell array, so you need to use curly braces to access its content:
images{ii}.Neighborhood
% ^ ^
TITLES is also a cell array, so you will need to do the same there too.

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by