필터 지우기
필터 지우기

Problem in format for a txt file output (non return to line)

조회 수: 1 (최근 30일)
judy abbott
judy abbott 2016년 4월 2일
댓글: judy abbott 2016년 4월 2일
Hy all, for a txt file output, i get an non return to line
V_Ref = {'Ref_1'; 'Ref_2'};
Nbr_Ref = length(V_Ref);
V_A1 = {'A_1'; 'A_2'}; V_A2 = {'B_2'; 'B_2'}; V_A3 = {'C_3'; 'C_2'};
V_B1 = {'D_1'; 'D_2'}; V_B2 = {'E_1'; 'E_2'}; V_B3 = {'F_1'; 'F_2'};
file_Out = fopen('My_OUT.txt','w');
for i=1:Nbr_Ref
M_A{i} = [V_Ref{i} V_A1{i} V_A2{i} V_A3{i}];
fprintf(file_Out,'%6s %12s %18s %24s \n',M_A{i});
M_B{i} = [V_Ref{i} V_B1{i} V_B2{i} V_B3{i}];
fprintf(file_Out,'%6s %12s %18s %24s \n',M_B{i});
end
fclose(file_Out);
I get this
Ref_1A_1B_2C_3 Ref_1D_1E_1F_1 Ref_2A_2B_2C_2 Ref_2D_2E_2F_2
But i want to get
Ref_1 A_1 B_2 C_3
Ref_2 A_2 B_2 C_2
Ref_1 D_1 E_1 F_1
Ref_2 D_2 E_2 F_2

채택된 답변

Walter Roberson
Walter Roberson 2016년 4월 2일
M_A = {V_Ref{i} V_A1{i} V_A2{i} V_A3{i}};
fprintf(...., M_A{:})
  댓글 수: 3
Walter Roberson
Walter Roberson 2016년 4월 2일
Use two loops instead of one
judy abbott
judy abbott 2016년 4월 2일
Sorry, It's so Simple

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Electrical Block Libraries에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by