MATLAB is mostly a computing platform popular among engineers and data scientists. Most of MATLAB uses surround analyzing and visualizing a data set making it an amazing tool to analyze your Excel spreadsheet.
MATLAB is flexible when it comes to importing data; therefore, you can easily import an Excel spreadsheet into the MATLAB program.
How to Import Excel into MATLAB?
The MATLAB interface is pretty simple and beginner-friendly. This makes navigating the import option pretty straightforward. Additionally, if you often find yourself in need of importing Excel into MATLAB, the program has the option for you to create a code the next time you wish to import a .xlsx file.
While importing your data, you will get the option to select an Output Type. You can either import the data as a Table, Column Vector, Numeric Matrix, String Array, or Cell Array. Similarly, MATLAB also gives you the option to choose what you wish to do with cells that are deemed uncomfortable. Such cells are usually the ones that are empty.
From the Home Tab
The easiest way to import any file, including an Excel file, is from the Home tab of MATLAB.
- Open MATLAB and head to the Home tab.
- Look for and select Import Data from the VARIABLE section.
- Locate and open your Excel file from File Explorer.
- From the IMPORT tab, select the data you wish to import. You can either select and drag your cursor to make the selection to set the range next to the Range option in the SELECTION section.
- Under Output Type in the IMPORTED DATA section, select how you wish to import your data as.
- Choose how you wish empty cells to be exported in the UNIMPORTABLE CELLS section.
- After you make the configurations, select Import Selection in the IMPORT tab.
- Head back to the previous window and locate your data under Workspace.
- Double-click on your data.
Create a Function to Import Excel Sheet to MATLAB
If you frequently import files from Excel to MATLAB, you may find the method we discussed above pretty long and tedious. You can instead let MATLAB automate a function after you make your first import and then save it to use in the future. This will save you plenty of time you would otherwise be spending in importing your data.
- Use the Home tab to import your data.
- After configuring the selection and the output type, select the fly-out menu under Import Selection.
- Choose Generate Function.
- Save the function from the FILE section in the Editor tab.
- To import a sheet in the future, set up your Current Folder window by entering its path.
- Under the Command Window section, enter your command in the following format:
importfile(‘(filename)’)
- Hit Enter.
- View your data by double-clicking on it under the Workspace section.