How to assign existing material to an object ?

I know how to access object’s material list:

obj.GetComponent<MeshRenderer>().material = ???

However, what should go in ??? The material already exists in my Assets folder as .mat file. I run this script in editor NOT at runtime. The result should be equivalent to manually (with mouse clicks) assigning material in Inspector->MeshRenderer. Resources.Load is the weirdest function I have seen so far and I don’t want to use it. AssetDatabase.LoadAssetAtPathdoesn’t work.

@szpaq234
The method below will load the material named “MyMaterial” which is located in your “Assets/Resources/Materials/” folder.

    void LoadMaterial ()
    {
        private string materialName = "MyMaterial";

        Material m = Resources.Load<Material>("Materials/" + materialName) as Material;
        Material[] materials = GetComponent<MeshRenderer>().materials;
        
        if (materials.Length > 0)
        {
            materials[0] = m;
            GetComponent<MeshRenderer>().materials = materials;
        }
    }