About 3,250,000 results
Open links in new tab
  1. fscanf - MathWorks

    A = fscanf(fileID,formatSpec) reads data from an open text file into column vector A and interprets values in the file according to the format specified by formatSpec. The fscanf function reapplies the format throughout the entire file and positions the file pointer at the end-of-file marker.

  2. readcell - MathWorks

    C = readcell(filename) creates a cell array by reading column-oriented data from a text or spreadsheet file. C = readcell(filename,Name,Value) specifies options using one or more name-value arguments. For example, you can specify the number of header lines in the file, the expected number of variables or columns, or a range of data to read.

  3. Import Text Files - MathWorks

    You can import non-uniform data (each column having a different type) from a text file into a cell array using readcell. For example, display the contents of basic_cell.txt , and then import the mixed data into a cell array.

  4. reading a text file to MATLAB with different formatting

    Aug 28, 2012 · fid = fopen('test.txt', 'rt'); data = textscan(fid, '%*u %*1s %f', 'Delimiter', ';'); fclose(fid); Change test.txt to your filename. data is a cell with your doubles in it.

  5. how to open a formatted text file in MATLAB - Stack Overflow

    Apr 6, 2017 · Here's an inelegant solution, assuming the text file is called test.txt in the current directory. txt = fileread('test.txt'); A = strsplit(txt,'\n'); . B = cellfun(@(x) x(2:end-1),A,'uniformoutput',0); . C = cellfun(@(x) strsplit(x,','),B,'uniformoutput',0); D = cellfun(@(x) cellfun(@str2num,x),C','uniformoutput',0); . NumArray = cell2mat(D); .

  6. How to Read a Text File in MATLAB: The Complete 2023 Guide

    Dec 27, 2023 · Reading Formatted Text Data with fscanf() The fscanf() function allows reading formatted numeric values from text files into MATLAB variables. Consider our sample data.txt file: 1001 24 M 1002 34 F 1003 28 M. We can easily parse it as follows:

  7. reading formatted data from text file in matlab - Stack Overflow

    Nov 24, 2015 · Make sure that you are using the correct number of %f format specifiers in your format string. It looks like you probably need to use the following format statement: format =['L%d,',repmat('%f,' , 1 , num_ints-2),'%f']; %% changed to ( num_ints - 2) assuming that num_ints is the number of columns.

  8. textscan - MathWorks

    C = textscan(fileID,formatSpec) reads data from an open text file into a cell array, C. The text file is indicated by the file identifier, fileID . Use fopen to open the file and obtain the fileID value.

  9. Read data from .txt file - MATLAB Answers - MATLAB Central

    Oct 11, 2022 · We recommend upgrading to get the newer decimal separator support. If that is not possible then you will need to read the file as text and replace the comma with period that then interpret the numbers.

  10. Reading & Writing FilesMATLAB Programming for …

    To read the contents of a free-format text file, fileread() or fgetl() is used, depending on whether the objective is to read the file all at once or line-by-line. The fileread() function returns the entire contents of the file as a character array:

  11. Some results have been removed
Refresh