How to read file in matlab?

前端 未结 3 501
再見小時候
再見小時候 2021-01-05 14:14

I have a txt file, and the content of the file is rows of numbers, each row have 5 float number in it, with comma seperate between each number. example:

1.1 , 12 , 1

相关标签:
3条回答
  • 2021-01-05 14:41

    The answer is surprisingly simple:

    fid = fopen('depthMap.txt');
    A = fscanf(fid, '%f');
    fclose(fid);
    
    0 讨论(0)
  • 2021-01-05 14:44

    MATLAB's built-in dlmread function would be a much easier solution for what you want to accomplish.

    A = dlmread('filename.txt',',') % call dlmread and specify a comma as the delimiter
    
    0 讨论(0)
  • 2021-01-05 14:52

    try with using importdata function

    A = importdata(`filename.txt`);
    

    It will solve your question.

    EDIT

    Alternative 1)

    A = dlmread('test_so.txt',',');
    
    0 讨论(0)
提交回复
热议问题