# MATLAB: Understanding eye / identity matrix in matlab

identitymachine learningmatrixvectors

Hello,
I am working with a machine learning alogrithm and these two lines of code have helped me but I still do not understand what they do exactly, specially the last one
``eye_matrix = eye(10); y_matrix = eye_matrix(y, :);``
so 'y' is a vector consisting of numbers of 1 to 10 i.e: y = [1;2;3;4;5;6;7;8;9;10]
The result y matrix is a matrix with 10 rows and 10 columns, every row has zeros everywhere, but one in an index of the corresponding row value in y.
can someone how did we achieve this, and how the second line of code works.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9095604,"math_prob":0.94119513,"size":544,"snap":"2022-27-2022-33","text_gpt3_token_len":151,"char_repetition_ratio":0.10185185,"word_repetition_ratio":0.0,"special_character_ratio":0.28860295,"punctuation_ratio":0.16666667,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9931389,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-07-05T18:09:18Z\",\"WARC-Record-ID\":\"<urn:uuid:a930cf71-6ec0-4444-8b68-14a00e832b3c>\",\"Content-Length\":\"19060\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:10217683-5b47-47a2-bba6-70cb77d2e080>\",\"WARC-Concurrent-To\":\"<urn:uuid:2b83d453-e5ae-4356-9e4f-a452469639fa>\",\"WARC-IP-Address\":\"45.77.5.190\",\"WARC-Target-URI\":\"https://imathworks.com/matlab/matlab-understanding-eye-identity-matrix-in-matlab/\",\"WARC-Payload-Digest\":\"sha1:MQ32453U7SOAWJZ27BBZGOKVF2D7P3PT\",\"WARC-Block-Digest\":\"sha1:XNICZIH55TME2HTAI4C6MCWJKVN3HEPY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-27/CC-MAIN-2022-27_segments_1656104597905.85_warc_CC-MAIN-20220705174927-20220705204927-00277.warc.gz\"}"}