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.

16 lines
507B

  1. function [ ipaddress ] = getLocalIP()
  2. %GETLOCALIP returns the ipaddress of the current windows machine
  3. [status,result]=system('ipconfig');
  4. if ~(status == 0)
  5. error('Failed to find local IP address');
  6. end
  7. [startIndex,endIndex] = regexp(result,'(?<=\n IPv4 Address[ \.]*: )([0-9]{1,3}\.?){4}');
  8. if isempty(startIndex)
  9. error('Failed to find local IP address');
  10. end
  11. for i = 1:length(startIndex)
  12. ipaddress{i} = result(startIndex(i):endIndex(i));
  13. end
  14. end