fprintf columns turning out weirdly
Afficher commentaires plus anciens
So I've got some sets of data and their all columns, such as the example below. As obvious x and y both become column matrices of 11 x 1. I try and get these to print like x(1) y(1)
x(2) y(2)
Which I can
Attempt 4 works for this short example, but with my problem which has lots more values and such it doesnt work, it still prints the values out horizontally. With my problem in my code with lots of data (which I will attatch) it prints out the values, semi correctly, but in a weird kind of way. I am printing some time values then some fitted time values, repeat this 4 times to have a total of 8 arrays of values I am trying to print. So thats why it will go .165 .165. It's all fine up untill the last two columns, the tjohn1 and tf4 (tf4 is the fitted time for john). It prints the intial values of these two columns underneath the first two columns and so the data when printed looks all funky.
Why would It print like this, it's like it's running out of horizontal space in the window and so it jams it underneath the first two columns and how would I fix this?
x = 0:1:10;
x = x'
y = 1:1:11;
y = y'
z =
fprintf('%2.2f | %2.2f \n', [x'; y';]) %This works for this small example
0.00 | 1.00
1.00 | 2.00
2.00 | 3.00
3.00 | 4.00
4.00 | 5.00
5.00 | 6.00
6.00 | 7.00
7.00 | 8.00
8.00 | 9.00
9.00 | 10.00
10.00 | 11.00
%However in my coding, it prints out like this
0.165 0.165 0.142 0.142 0.193 0.193
0.129 0.129 1.850 1.825 1.890 1.791
1.940 1.878 1.840 1.810 2.870 2.793
2.880 2.751 2.960 2.866 2.860 2.795
3.780 3.687 3.780 3.637 3.910 3.780
3.800 3.705 4.650 4.555 4.640 4.497
4.780 4.669 4.670 4.590 5.500 5.415
5.470 5.348 5.640 5.549 5.530 5.467
6.320 6.271 6.290 6.195 6.500 6.425
6.380 6.340 7.140 7.125 7.100 7.041
7.360 7.301 7.230 7.212 7.960 7.980
7.920 7.887 8.220 8.177 8.100 8.084
8.790 8.835 8.750 8.733 9.070 9.053
8.960 8.957 9.690 9.690 9.580 9.580
9.930 9.930 9.830 9.830 %as seen, the two .129's are jammed under the first two columns, where I want them beside the .193 columns
4 commentaires
Ameer Hamza
le 28 Sep 2020
You didn't attach sprint.dat file.
Liam Crocker
le 28 Sep 2020
Liam Crocker
le 28 Sep 2020
Liam Crocker
le 28 Sep 2020
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Data Type Identification dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!