?? imread() already creates a matrix to store the information. The matrix returned by imread() is that matrix.
If you want to look at a particular x, y location in the matrix, then the sequence would look like
img = imread('YourFileNameGoesHere.png');
x_of_interest = 17;
y_of_interest = 83;
pixel_value_at_x_y = img(y_of_interest, x_of_interest, :);
Note that y is the row index, and that x is the column index.
Note that if you wanted to examine a number of individual pixels, then you would need a different solution:
x_of_interest = [17 17 184];
y_of_interest = [83 84 5];
[rows, columns, panes] = size(img);
ind = sub2ind([rows, columns], y_of_interest, x_of_interest);
pixel_value_at_x_y(:,1) = img(ind + 0*rows*columns);
pixel_value_at_x_y(:,2) = img(ind + 1*rows*columns);
pixel_value_at_x_y(:,3) = img(ind + 2*rows*columns);
then the first row would be the R then G then B components for x = 17, y = 83, and the second row would be RGB for x = 17, y = 84, and the third row would be RGB for x = 184, y = 5.
Or you could simply loop:
x_of_interest = [17 17 184];
y_of_interest = [83 84 5];
for K = 1 : length(x_of_interest)
pixel_value_at_x_y(K, :) = img(y_of_interest(K), x_of_interest(K), :);
end
The way I used with sub2ind() takes more understanding of how images are stored and how subscripts are calculated. Because looping is a lot clearer for most people, I would recommend using the loop unless you are extracting values at a lot of different locations.