I have the following function whose last argument is a name of the text file:
function [property_without_headers]=gslib_file_to_matlab_var(nModel,nCell,gslib_file_name) % must enter the last argument, gslib_file_name, in single quotes as its treated as a string
if nargin<3, % making third argument optional (code to be executed even when only 2 arguments are provided)
gslib_file_name=input('Enter the gslib file name: ','s');
end
if length(gslib_file_name)<4 || ~strcmpi(gslib_file_name(end-3:end),'.dat'),
gslib_file_name=[gslib_file_name '.dat']; % string concatenation
end
%% Reading directly from the .dat files generated from SGEMS and making the data of file as a variable
property_gslib_format=textread(gslib_file_name,'%f\t','headerlines',nModel+2);
property_without_headers=reshape(property_gslib_format,nModel,nCell)';
Right now it seems, through general perception, that the function's last argument to be entered is numeric. How can I make it more clear for the user that the last argument, the name of the text file, to be entered should be in string format i.e. in single quotes? If I define the last argument of the function like following then I get an error of Unexpected MATLAB expression.:
[property_without_headers]=gslib_file_to_matlab_var(nModel,nCell,'gslib_file_name')