Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. %my knowledge of parallel computing is basic so I just used PARFOR
  2. parfor i = 1:initn
  3. init_pop(i,:) = fmincon(@(x)dis_px(new_wavelength(:,i), x),
  4. randi([0,500],1,n), ...
  5. [], [], [], [], LB(1:n),UB(1:n), [], optimset('display',
  6. 'off'));
  7. end
  8.  
  9. function [Z,Y]=Results()
  10. Para_num=10;
  11. Z=zeros(1,Para_num);
  12. Y=zeros(1,Para_num);
  13. fid=fopen('G:costans.Z5','r+t');
  14. c=0;
  15. %the error refers to this part ***while***%
  16. while ~feof(fid)
  17. tline = fgetl(fid);
  18. c=c+1;
  19. end
  20. fclose(fid);
  21. num_lines = c;
  22. one_less = c-1;
  23. fidin=fopen('G:costans.Z5','r+t');
  24. for i = 1:num_lines
  25. E=fgetl(fidin);
  26. if i == one_less
  27. Z(1:4)=str2num(E);
  28. elseif i == num_lines
  29. Z(5:6)=str2num(E);
  30. end
  31. end
  32. fclose(fidin);
  33. fid=fopen('G:costans.Z1','r+t');
  34. c=0;
  35. while ~feof(fidin)
  36. tline = fgetl(fidin);
  37. c=c+1;
  38. end
  39. fclose(fid);
  40. num_lines2 = c;
  41. one_less2 = c-1;
  42. fidin=fopen('G:costans.Z1','r+t');
  43. for i = 1:num_lines2
  44. E=fgetl(fidin);
  45. if i == one_less2
  46. Y(1:4)=str2num(E);
  47. elseif i == num_lines2
  48. Y(5:6)=str2num(E);
  49. end
  50. end
  51. fclose(fidin);
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement