MATLAB: Upload txt file for a matrix MATLABupload file i can make a comma delimited .txt file with 3 columns and say 5 rows. I need to make a 3×5 matrix from this file. thank you david Best Answer check out dlmread()https://www.mathworks.com/help/matlab/ref/dlmread.htmlor textscan()https://www.mathworks.com/help/matlab/ref/textscan.html Related SolutionsMATLAB: Saving data in .dat files There is no specific format for a .dat file. You can use writematrix(): https://www.mathworks.com/help/releases/R2020a/matlab/ref/writematrix.html or dlmwrite(): https://www.mathworks.com/help/releases/R2020a/matlab/ref/dlmwrite.html in older versions.For example,writematrix(sr, 'filename.dat') % or dlmwrite('filename.dat', sr); MATLAB: Importing .txt matrix Read it using these linesfiletxt = fileread('m1.txt');filetxt = strrep(filetxt, ',', '.');data = cell2mat(textscan(filetxt, '%f%f%f%f')) Related QuestionHow to read file using textscanHow to upload a txt file to solve a function multiple instances at once
Best Answer