Bird
0
0

Which of the following is the correct syntax to extract the file extension from a path in MATLAB?

easy📝 Syntax Q3 of 15
MATLAB - File I/O
Which of the following is the correct syntax to extract the file extension from a path in MATLAB?
Aext = dir(path);
Bext = fullfile(path);
C[~,~,ext] = fileparts(path);
Dext = pwd(path);
Step-by-Step Solution
Solution:
  1. Step 1: Recall fileparts output

    fileparts returns folder, name, and extension as three outputs.
  2. Step 2: Use correct syntax to get extension

    Using [~,~,ext] = fileparts(path) assigns the extension to ext.
  3. Final Answer:

    [~,~,ext] = fileparts(path); -> Option C
  4. Quick Check:

    Extract extension with fileparts [OK]
Quick Trick: Use [~,~,ext] = fileparts(path) to get extension [OK]
Common Mistakes:
  • Using fullfile to get extension
  • Using dir or pwd incorrectly
  • Not using three output variables

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More MATLAB Quizzes