Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Recursive Programming | Recursion and Matrix Multiplication
Matlab Basics
course content

Conteúdo do Curso

Matlab Basics

Matlab Basics

1. Basic Syntax and Coding with a Text Editor
2. Coding Foundations
3. Learning Through Applications
4. Visualizations
5. Recursion and Matrix Multiplication

book
Recursive Programming

Recursive programming, or having a program call itself, is a fundamental aspect of programming that serves a unique role. Here you'll learn how to write a recursive program that searches through a tree of subfolders and identifies those containing files of interest. Having this tool in hand allows you to automate your analyses and graphing across libraries of data files at the push of a button.

Task

Download the program Identify_Relevant_Subfolders_N_C.

  1. Modify the variable number_of_hidden_system_files based on your operating system, as shown in the video:

    • Create a blank folder on your desktop;
    • Use the dir function to retrieve its directory (see Section 4, Chapter 5). Assign a variable to collect the output;
    • Look at how many rows are in the returned structure, and change number_of_hidden_system_files to this number.
  2. Create a random tree of folders, some containing Excel files, some not, and run Identify_Relevant_Subfolders_N_C on the parent folders.

  3. Check to see if it identified all the subfolders that you put Excel files in. In your future programming, if you need to run analyses or graphing on files contained within a directory of folders, you can:

    • Run Identify_Relevant_Subfolders_N_C (perhaps changing the extension of the file types you're looking for) on the parent folder to get a list of all the subfolders of interest;
    • Create a module to for loop over that list of subfolders, using the dir function to pull each folder's contents and perhaps some if statements to focus on certain files, and run your analyses/graphing on each one.

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 5. Capítulo 1
We're sorry to hear that something went wrong. What happened?
some-alt