You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: loadPoleFigure_pwd.m
    path of file: ./repos/mtex/interfaces
    
    the code of the file until where you have to start completion: function pf = loadPoleFigure_pwd(fname,varargin)
% load D5000 powder data file
%
% Syntax
%   pf = loadPoleFigure_pwd(fname)
%
% Input
%  fname - file name
%
% Output
%  pf    - @PoleFigure
%
% See also
% loadPoleFigure ImportPoleFigureData

assertExtension(fname,'.pwd');

% open the file
fid = fopen(fname,'r');


    
function pf = loadPoleFigure_pwd(fname,varargin)
% load D5000 powder data file
%
% Syntax
%   pf = loadPoleFigure_pwd(fname)
%
% Input
%  fname - file name
%
% Output
%  pf    - @PoleFigure
%
% See also
% loadPoleFigure ImportPoleFigureData

assertExtension(fname,'.pwd');

% open the file
fid = fopen(fname,'r');

try
  p = 0;
  while ~feof(fid)
    line = fgetl(fid);
    
    % lines starting with indicates a new pole figure
    if strfind(line,'R')
      
      p = p+1; k=1;
      allH{p} = string2Miller(line(2:end