Terminal command that gives the type of computer you're on I am running MATLAB code on two different computers, both with the same username. 

I would like to distinguish between the two Macs by having the code identify that one system is a desktop, and the other a laptop. 

Is there a Terminal command that will print the type of computer I am using (so I can implement the relevant function?)
This command should work for you:

sysctl hw.model


This will return the Model Identifier for your machine. The below is an example for a mid-2012 Retina MacBook Pro:

Machine123:~ username$ sysctl hw.model
hw.model: MacBookPro10,1


Below are some references on Apple's site that describe Model Identifiers - there doesn't seem to be a single reference:

MacBook Pro Model Identifiers

MacBook Model Identifiers

MacBook Air Model Identifiers

iMac Model Identifers

Mac Pro Model Identifiers

Mac Mini Model Identifiers