您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

24 行
776B

  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. [status,result]=system('ifconfig');
  13. if ~(status == 0)
  14. error('Failed to find local IP address');
  15. end
  16. ipaddress = regexp(result,'(?<=\n inet )([0-9]{1,3}\.?){4}','match');
  17. elseif isunix
  18. % Code to run on Unix platform
  19. else
  20. error('Platform not supported');
  21. end
  22. end