Write a function that will prompt the user separately for a filename and extension and will create and return a string with the form ‘filename.ext’
belongs to book: MATLAB: A Practical Introduction to Programming and Problem Solving|Stormy Attaway|Fourth Edition| Chapter number:7| Question number:11.7
All Answers
total answers (1)
getfilename.m
function file = getfilename
% Prompts user for filename and extension and combines them
% Format of call: getfilename or getfilename()
% Returns one string of the form filename.ext
fname = input('Enter filename: ','s');
extension = input('Enter extension: ','s');
file = sprintf('%s.%s',fname,extension);
end
need an explanation for this answer? contact us directly to get an explanation for this answer