You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
571B

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