MATLAB: How to combine two text files having different columns in one file text file I have two text files need to be combined to one. a.txt b.txt 1 2 44 3 6 i need like this c.txt1 2 44 3 6 Best Answer a=dlmread('a.txt');b=dlmread('b.txt');c=[a,b];dlmwrite('c.txt',c); Related SolutionsMATLAB: I want to delete all the headerlines and delimiters from the data in the below attached text file The best solution is probably to read your entire file as text, then remove the header lines, then parse them with textscan. MATLAB: Concatenate data using fgets You are closing the file in the loop. close the file after the loop. I assume the below should work.function read_datapattern(filename)fid = fopen(filename,'rt');if fid < 0 error('error opening file %s\n\n',filename);endpattern = fgets(fid);for n = 1:32767 nextline = fgets(fid); pattern = strcat(pattern, nextline);fprintf(pattern);fprintf('\n');endfclose(fid); Related QuestionTo read a text file using matlab
Best Answer