Effacer les filtres
Effacer les filtres

I want to use fprintf to make a table of results

3 vues (au cours des 30 derniers jours)
Carlos Puente
Carlos Puente le 16 Mar 2023
Modifié(e) : Voss le 17 Mar 2023
I am using fprintf to make a table of results. I want two separate vectors to be printed in two separated columns (standard in one column and average in other column).
But as you may notice, that is not happening, because the two vectors are being printed in sequence.
I don't know how to solve this.
standard = [7.5156
7.2832
7.2556
6.9506
6.3206
5.8448
5.4522
5.1111
4.8075
4.5315
4.2770
4.0401
3.8186
3.6102
3.4141
3.2290
3.0544
2.8893
2.7330
2.5855
2.4458
2.3139
2.1891
2.0709
1.9591
1.8533
1.7534
1.6588
1.5691
1.4845
1.4042
1.3285
1.2567
1.1890
1.1248
1.0640
1.0067
0.9523
0.9010
0.8524
0.8065
0.7630
0.7218
0.6829
0.6460
0.6110
0.5781
0.5468
0.5173
0.4895
0.4631
0.4381
0.4144
0.3921
0.3709
0.3508
0.3319
0.3140
0.2969
0.2810
0.2658
0.2515
0.2378
0.2250
0.2128
0.2013
0.1905
0.1802
0.1706
0.1615
0.1528
0.1446
0.1368
0.1294
0.1224
0.1158
0.1096
0.1037
0.0980
0.0927
0.0877
0.0828
0.0783
0.0741
0.0701
0.0663
0.0628
0.0595
0.0562
0.0532
0.0504
0.0476
0.0450
0.0424
0.0402
0.0380
0.0360
0.0340
0.0323
0.0306
0.0290
0.0275
0.0259
0.0245
0.0233
0.0221
0.0208
0.0196
0.0186
0.0176
0.0166
0.0157
0.0148
0.0140
0.0133
0.0125
0.0118
0.0110
0.0104
0.0099
0.0094
0.0090
0.0085
0.0082
0.0078
0.0074
0.0070
0.0065
0.0061
0.0059
0.0055
0.0052
0.0050
0.0047
0.0044
0.0042
0.0040
0.0037
0.0034
0.0033];
average = [306.6108
309.0169
311.2043
313.4392
315.6969
317.7413
319.6286
321.3879
323.0361
324.5860
326.0465
327.4248
328.7266
329.9569
331.1200
332.2200
333.2603
334.2444
335.1752
336.0557
336.8886
337.6766
338.4220
339.1273
339.7945
340.4256
341.0227
341.5875
342.1219
342.6274
343.1057
343.5581
343.9861
344.3910
344.7740
345.1364
345.4792
345.8035
346.1104
346.4007
346.6753
346.9351
347.1809
347.4134
347.6334
347.8415
348.0384
348.2247
348.4008
348.5675
348.7252
348.8744
349.0155
349.1490
349.2753
349.3948
349.5078
349.6147
349.7159
349.8116
349.9021
349.9877
350.0687
350.1453
350.2178
350.2864
350.3513
350.4127
350.4708
350.5257
350.5777
350.6269
350.6735
350.7176
350.7593
350.7987
350.8360
350.8713
350.9046
350.9362
350.9661
350.9943
351.0210
351.0462
351.0701
351.0927
351.1141
351.1343
351.1535
351.1716
351.1887
351.2049
351.2202
351.2347
351.2484
351.2614
351.2736
351.2852
351.2962
351.3066
351.3164
351.3258
351.3346
351.3430
351.3509
351.3584
351.3655
351.3722
351.3785
351.3845
351.3902
351.3955
351.4006
351.4054
351.4099
351.4141
351.4181
351.4219
351.4255
351.4289
351.4321
351.4352
351.4381
351.4408
351.4434
351.4459
351.4483
351.4505
351.4526
351.4546
351.4565
351.4582
351.4599
351.4615
351.4630
351.4644
351.4657
351.4670
351.4682
351.4693];
fprintf('=====================================\n')
fprintf('Standard Deviation Average\n')
fprintf('every 10 values every 10 values\n')
fprintf('=====================================\n')
fprintf(' %6.3f %6.3f\n', standard', average')
fprintf('=====================================\n')
=====================================
Standard Deviation Average
every 10 values every 10 values
=====================================
7.516 7.283 7.256 6.951 6.321 5.845 5.452 5.111 4.808 4.532 4.277 4.040 3.819 3.610 3.414 3.229 3.054 2.889 2.733 2.586 2.446 2.314 2.189 2.071 1.959 1.853 1.753 1.659 1.569 1.484 1.404 1.329 1.257 1.189 1.125 1.064 1.007 0.952 0.901 0.852 0.806 0.763 0.722 0.683 0.646 0.611 0.578 0.547 0.517 0.489 0.463 0.438 0.414 0.392 0.371 0.351 0.332 0.314 0.297 0.281 0.266 0.252 0.238 0.225 0.213 0.201 0.191 0.180 0.171 0.162 0.153 0.145 0.137 0.129 0.122 0.116 0.110 0.104 0.098 0.093 0.088 0.083 0.078 0.074 0.070 0.066 0.063 0.059 0.056 0.053 0.050 0.048 0.045 0.042 0.040 0.038 0.036 0.034 0.032 0.031 0.029 0.028 0.026 0.025 0.023 0.022 0.021 0.020 0.019 0.018 0.017 0.016 0.015 0.014 0.013 0.013 0.012 0.011 0.010 0.010 0.009 0.009 0.009 0.008 0.008 0.007 0.007 0.006 0.006 0.006 0.005 0.005 0.005 0.005 0.004 0.004 0.004 0.004 0.003 0.003 306.611 309.017 311.204 313.439 315.697 317.741 319.629 321.388 323.036 324.586 326.046 327.425 328.727 329.957 331.120 332.220 333.260 334.244 335.175 336.056 336.889 337.677 338.422 339.127 339.795 340.426 341.023 341.587 342.122 342.627 343.106 343.558 343.986 344.391 344.774 345.136 345.479 345.803 346.110 346.401 346.675 346.935 347.181 347.413 347.633 347.841 348.038 348.225 348.401 348.567 348.725 348.874 349.015 349.149 349.275 349.395 349.508 349.615 349.716 349.812 349.902 349.988 350.069 350.145 350.218 350.286 350.351 350.413 350.471 350.526 350.578 350.627 350.673 350.718 350.759 350.799 350.836 350.871 350.905 350.936 350.966 350.994 351.021 351.046 351.070 351.093 351.114 351.134 351.154 351.172 351.189 351.205 351.220 351.235 351.248 351.261 351.274 351.285 351.296 351.307 351.316 351.326 351.335 351.343 351.351 351.358 351.365 351.372 351.378 351.385 351.390 351.396 351.401 351.405 351.410 351.414 351.418 351.422 351.425 351.429 351.432 351.435 351.438 351.441 351.443 351.446 351.448 351.450 351.453 351.455 351.457 351.458 351.460 351.462 351.463 351.464 351.466 351.467 351.468 351.469
=====================================

Réponses (1)

Voss
Voss le 16 Mar 2023
Modifié(e) : Voss le 16 Mar 2023
fprintf(' %6.3f %6.3f\n', [standard, average].')
  2 commentaires
Carlos Puente
Carlos Puente le 16 Mar 2023
I have already tried that, and it doesn't fix my problem.
Voss
Voss le 17 Mar 2023
Let me run it here... What's wrong with it?
load data.mat % I stored the variables in a mat file to avoid them taking up space here
fprintf('=====================================\n')
fprintf('Standard Deviation Average\n')
fprintf('every 10 values every 10 values\n')
fprintf(' %6.3f %6.3f\n', [standard, average].')
fprintf('=====================================\n')
=====================================
Standard Deviation Average
every 10 values every 10 values
=====================================
7.516 306.611 7.283 309.017 7.256 311.204 6.951 313.439 6.321 315.697 5.845 317.741 5.452 319.629 5.111 321.388 4.808 323.036 4.532 324.586 4.277 326.046 4.040 327.425 3.819 328.727 3.610 329.957 3.414 331.120 3.229 332.220 3.054 333.260 2.889 334.244 2.733 335.175 2.586 336.056 2.446 336.889 2.314 337.677 2.189 338.422 2.071 339.127 1.959 339.795 1.853 340.426 1.753 341.023 1.659 341.587 1.569 342.122 1.484 342.627 1.404 343.106 1.329 343.558 1.257 343.986 1.189 344.391 1.125 344.774 1.064 345.136 1.007 345.479 0.952 345.803 0.901 346.110 0.852 346.401 0.806 346.675 0.763 346.935 0.722 347.181 0.683 347.413 0.646 347.633 0.611 347.841 0.578 348.038 0.547 348.225 0.517 348.401 0.489 348.567 0.463 348.725 0.438 348.874 0.414 349.015 0.392 349.149 0.371 349.275 0.351 349.395 0.332 349.508 0.314 349.615 0.297 349.716 0.281 349.812 0.266 349.902 0.252 349.988 0.238 350.069 0.225 350.145 0.213 350.218 0.201 350.286 0.191 350.351 0.180 350.413 0.171 350.471 0.162 350.526 0.153 350.578 0.145 350.627 0.137 350.673 0.129 350.718 0.122 350.759 0.116 350.799 0.110 350.836 0.104 350.871 0.098 350.905 0.093 350.936 0.088 350.966 0.083 350.994 0.078 351.021 0.074 351.046 0.070 351.070 0.066 351.093 0.063 351.114 0.059 351.134 0.056 351.154 0.053 351.172 0.050 351.189 0.048 351.205 0.045 351.220 0.042 351.235 0.040 351.248 0.038 351.261 0.036 351.274 0.034 351.285 0.032 351.296 0.031 351.307 0.029 351.316 0.028 351.326 0.026 351.335 0.025 351.343 0.023 351.351 0.022 351.358 0.021 351.365 0.020 351.372 0.019 351.378 0.018 351.385 0.017 351.390 0.016 351.396 0.015 351.401 0.014 351.405 0.013 351.410 0.013 351.414 0.012 351.418 0.011 351.422 0.010 351.425 0.010 351.429 0.009 351.432 0.009 351.435 0.009 351.438 0.008 351.441 0.008 351.443 0.007 351.446 0.007 351.448 0.006 351.450 0.006 351.453 0.006 351.455 0.005 351.457 0.005 351.458 0.005 351.460 0.005 351.462 0.004 351.463 0.004 351.464 0.004 351.466 0.004 351.467 0.003 351.468 0.003 351.469
=====================================

Connectez-vous pour commenter.

Catégories

En savoir plus sur Programmatic Model Editing dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by