Merge columns and export to a text file
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
Dear all,
I have array like that:
AB = [
    15.5000    4.3000
    13.9000    0.7000
    12.2000    6.9000
    11.5000    6.8000
    16.1000    0.7000
    17.1000   -0.6000
    ];
I need to convert it to the .txt (MS-DOS) in this form:
15.5000,4.3000
13.9000,0.7000
12.2000,6.9000
11.5000,6.8000
16.1000,0.7000
17.1000,-0.6000
But there are two problems;
Firstly when I try to merge them using this code:
AB = char(compose('%0.f,%0.f', AB));
I observe that the decimal part didn't include in. for instance, I have -0 incorrect values in the new AB. 
Secondly, when I try to export them in a text file, I see some blank space after each row, for example:
" 15.5000,4.3000      "
But I don't want the " symbol and also blank spaces in the text file.
I tried everything I knew, but it's isn't accomplished well, So if anyone knows the solution, I would be grateful.
Best regards
댓글 수: 0
채택된 답변
  ANKUR KUMAR
      
 2021년 3월 10일
        Focusing on "I need to convert it to the .txt (MS-DOS) in this form:" in your question, this chunck of code might help you.
AB = [
    15.5000    4.3000
    13.9000    0.7000
    12.2000    6.9000
    11.5000    6.8000
    16.1000    0.7000
    17.1000   -0.6000
    ];
dlmwrite('test.txt',AB)
Attached the test.txt file for your reference.
추가 답변 (0개)
참고 항목
카테고리
				Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

