Effacer les filtres
Effacer les filtres

obtain element from a non defined array matlab

2 vues (au cours des 30 derniers jours)
Josep Llobet
Josep Llobet le 12 Déc 2022
Modifié(e) : Voss le 12 Déc 2022
I am looking to obtain the element of an array without the necessity of creating a new variable.
Currently I am using like:
img_ex = imread('peppers.png');
size_img_temp = size(img_ex)
size_img = size_img_temp(1)
But i would like to call the array element without the necessity of create a new variable.
Something like:
img_ex = imread('peppers.png');
size_img = anything_to(size(img_ex))
Aboiding the
Error: Invalid array indexing.
Thank you very much

Réponse acceptée

Voss
Voss le 12 Déc 2022
Modifié(e) : Voss le 12 Déc 2022
img_ex = imread('peppers.png');
size_img = subsref(size(img_ex),substruct('()',{1}))
size_img = 384
% for comparison:
size_img_temp = size(img_ex);
size_img = size_img_temp(1)
size_img = 384
Of course, with size specifically, you can do:
size_img = size(img_ex,1)
size_img = 384

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by