Problem in format for a txt file output (non return to line)
1 view (last 30 days)
Show older comments
judy abbott
on 2 Apr 2016
Commented: judy abbott
on 2 Apr 2016
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
0 Comments
Accepted Answer
Walter Roberson
on 2 Apr 2016
M_A = {V_Ref{i} V_A1{i} V_A2{i} V_A3{i}};
fprintf(...., M_A{:})
3 Comments
More Answers (0)
See Also
Categories
Find more on Electrical Block Libraries in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!