Bird
0
0

You want to create a full path to a file named 'data.csv' inside a folder 'results' located in the current directory. Which MATLAB code correctly does this?

hard📝 Application Q8 of 15
MATLAB - File I/O
You want to create a full path to a file named 'data.csv' inside a folder 'results' located in the current directory. Which MATLAB code correctly does this?
Afullfile('results', 'data.csv')
Bfullfile(pwd, 'results', 'data.csv')
Cfullfile('pwd', 'results', 'data.csv')
Dfullfile(pwd + '/results', 'data.csv')
Step-by-Step Solution
Solution:
  1. Step 1: Use pwd to get current directory

    pwd returns current folder path as string.
  2. Step 2: Use fullfile to join current folder, 'results', and filename

    fullfile(pwd, 'results', 'data.csv') correctly builds the full path.
  3. Final Answer:

    fullfile(pwd, 'results', 'data.csv') -> Option B
  4. Quick Check:

    Use pwd with fullfile for current folder paths [OK]
Quick Trick: Use pwd inside fullfile to start from current directory [OK]
Common Mistakes:
  • Using string 'pwd' instead of function pwd()
  • Concatenating strings with + operator
  • Omitting current directory path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes