You are looking for the following:
1) To check the type of computer on which MATLAB is executing, use: computer .
2) The following displays information about your Windows:
winqueryreg('HKEY_LOCAL_MACHINE',...
'Software\Microsoft\Windows NT\CurrentVersion','ProductName')
or in general, to get information about the OS, use: feature('GetOS').
3) To check number of processors, use: getenv('NUMBER_OF_PROCESSORS').
4) To check CPU information, use: feature('GetCPU').
5) To get information about cores, use: feature('numCores') .
6) To check memory used by MATLAB, total physical memory and some other information, use: memory.
Note that:
Some of the above are undocumented and taken from Yair Altman's blog.
Finally, to write data in a text file, you can use: fprintf .