MATLAB: How to read a txt file and associate variable to value just by reading the file

read filetxtvaluesvariable

I am trying to make my code smaller and in order to do that I want to just read a .txt file with variables like (rho, cd) and right under it specify the values for them. When the code request rho it automatically associates to the value for it. For example: test.txt file is:
rho, cd
1.2,0.4
So, I want to read the file and when needed the program already knows that rho = 1.2 and cd = 0.4.
PS: I want to do it just by reading the .txt file, without having to associate anything like rho = A(2,1).

Best Answer

See if the readtable function will do what you want.