필터 지우기
필터 지우기

obtain element from a non defined array matlab

조회 수: 2 (최근 30일)
Josep Llobet
Josep Llobet 2022년 12월 12일
편집: Voss 2022년 12월 12일
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

채택된 답변

Voss
Voss 2022년 12월 12일
편집: Voss 2022년 12월 12일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by