Ви не можете вибрати більше 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