function [ ipaddress ] = getLocalIP() %GETLOCALIP returns the ipaddress of the current windows machine if ispc % Code to run on Windows plaform [status,result]=system('ipconfig'); if ~(status == 0) error('Failed to find local IP address'); end ipaddress = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}','match'); elseif ismac % Code to run on Mac platform [status,result]=system('ifconfig'); if ~(status == 0) error('Failed to find local IP address'); end ipaddress = regexp(result,'(?<=\n inet )([0-9]{1,3}\.?){4}','match'); elseif isunix % Code to run on Unix platform else error('Platform not supported'); end end