Is it possible to use function for a fullfile or readmatrix data storage?
1 view (last 30 days)
I am trying to make a function in which I can access the particular path of the folder and from there, I want to use readmatrix to read the .txt file. I tried but it did not work out. Is it possible or does it make any sense to use? Or the functions can only be used for mathematical operations in Matlab.
Looking forward your response asap.
Shuba Nandini on 31 Aug 2023
I understand you want to create a function from where text file can be accessed using “readmatrix” function.
Using “ uigetdir” function, you can select the folder from which you want to retrieve the ‘.txt’ file. “uigetdir” opens a modal dialog box that displays the folders in the current working directory and returns the path that you select from the dialog box.
Please refer to the below example on how to get the ‘.txt’ file from the specified folder:
function readtextfile() % This function reads a .txt file using readmatrix
dname = uigetdir('C:\'); % select a folder
data = readmatrix('textfile.m') %select a .txt file
Please refer to the following documentation to know more about “uigetdir” and “readmatrix” functions:
I hope this helps you to retrieve the .txt file!