How can I make the spacing in a table more consistent? Also, how could i rearrange the table's names to match the one in part 2d?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
%Part A (matrix G)
clear all; clc;
type rec0506c.dat %displays content in file
grades = fopen('rec0506c.dat','r');
fgetl(grades); fgetl(grades);
G = fscanf(grades, '%*s%*s%f%f%f%*s \n',[3,7])';
frewind(grades);
%Part B (textscan)
fgetl(grades); fgetl(grades);
C= textscan(grades, '%s %s %f %f %f %s' );
A= cell2mat(C(3:5)) ;
N = C{1};
I = C{2} ;
fclose(grades);
%Part C (Means)
clc;
studentmean = mean(G')';
exammean = mean(G);
overallmean = (mean(exammean) + mean(studentmean))./2;
R = [G studentmean]
%Part D (Table)
P = flipud(sortrows(R,4))
NI = [N I];
num2cell(P);
O= (num2cell(P));
L= [NI O]';
bottom = [exammean,overallmean]
table = fopen('rec0506d.dat','w') ;
fprintf(table,'Name netID E1 E2 E2| AVE \n -----------------------------------------------------\n')
fprintf(table,'%s %s%13.0f%13.0f%13.0f|%13.2f \n',L{:})
fprintf(table,'--------------------------------------\n')
fprintf(table,'exam_AV = %2.2f %2.2f %2.2f | %2.2f \n', [exammean,overallmean])
fclose(table)
type rec0506d.dat
I want my graph to look like the one in part2d.
https://gyazo.com/7638f1192039b96bddcaad31fa84fe5b
When I run my code, I end up with a very demented table: https://gyazo.com/01ff7ec364fbdc51550a2f01143df431
0 commentaires
Réponses (1)
Voir également
Catégories
En savoir plus sur Text Files dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!