0

I'm working in a matlab script that open a group of text files and read their content. The content is XY double points, separated by " ". I save the readed values in a Array like this:

    dataArray= textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN, 'ReturnOnError', false);  

This work fine but problems appear when i open multiple files because put the data in a array od data. Here the code and example:

for i = 1:length(files) 
    %% Open the text file.
    fileID = fopen([path files{i}],'r');
        dataArray = cat(1, dataArray, textscan(fileID, formatSpec, 'Delimiter', delimiter, 'MultipleDelimsAsOne', true, 'EmptyValue' ,NaN, 'ReturnOnError', false));
    end

    %% Close the text file.
    fclose(fileID);
end

The result of this is:

enter image description here

Where each cell is

enter image description here

I want that all values appear continuous like in the second picture. What i'm doing wrong?

1
  • Can you upload a small working example (with files)? It actually looks as if you're doing everything correctly. Commented Nov 11, 2018 at 11:28

2 Answers 2

1

Cat should work, but for your example [dataArray; textscan(...)] looks even more convenient to me. Check first, whether what you load via textscan really has the format that you expect.

Sign up to request clarification or add additional context in comments.

Comments

1

Please note that at your example image you have different data types. Column 1 and 2 are of type double and 3 is of type cell. To concentrate all in one variable it is necessary that everything is of type double. Check your formatSpec variable.

Also, your example code is not working because of an additional end.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.