Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %my knowledge of parallel computing is basic so I just used PARFOR
- parfor i = 1:initn
- init_pop(i,:) = fmincon(@(x)dis_px(new_wavelength(:,i), x),
- randi([0,500],1,n), ...
- [], [], [], [], LB(1:n),UB(1:n), [], optimset('display',
- 'off'));
- end
- function [Z,Y]=Results()
- Para_num=10;
- Z=zeros(1,Para_num);
- Y=zeros(1,Para_num);
- fid=fopen('G:costans.Z5','r+t');
- c=0;
- %the error refers to this part ***while***%
- while ~feof(fid)
- tline = fgetl(fid);
- c=c+1;
- end
- fclose(fid);
- num_lines = c;
- one_less = c-1;
- fidin=fopen('G:costans.Z5','r+t');
- for i = 1:num_lines
- E=fgetl(fidin);
- if i == one_less
- Z(1:4)=str2num(E);
- elseif i == num_lines
- Z(5:6)=str2num(E);
- end
- end
- fclose(fidin);
- fid=fopen('G:costans.Z1','r+t');
- c=0;
- while ~feof(fidin)
- tline = fgetl(fidin);
- c=c+1;
- end
- fclose(fid);
- num_lines2 = c;
- one_less2 = c-1;
- fidin=fopen('G:costans.Z1','r+t');
- for i = 1:num_lines2
- E=fgetl(fidin);
- if i == one_less2
- Y(1:4)=str2num(E);
- elseif i == num_lines2
- Y(5:6)=str2num(E);
- end
- end
- fclose(fidin);
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement