Can anybody help me with the two questions below in the image? Thanks in advance

1 Ansicht (letzte 30 Tage)

Antworten (3)

Sulaymon Eshkabilov
Sulaymon Eshkabilov am 13 Mai 2021
% Simple and easy answer here is to use logical indexing and categorical array approaches along with table, e.g.:
ID = (1:10)';
ALL=[ID, PE EM PS]; % This is your predefined/already entered table of student grades.
EX2 = array2table(ALL,'VariableNames', {'ID', 'P_E', 'E_M', 'P_S'}); %Given data table. You can change table headers if needed.
CC = cell(size(ALL(:,2:4)));
CC(ALL(:,2:4)>90)={'A'};
CC(ALL(:,2:4)<=90 & ALL(:,2:4)>80)={'B'}
CC(ALL(:,2:4)<=80 & ALL(:,2:4)>70)={'C'}
CC(ALL(:,2:4)<=70 & ALL(:,2:4)>60)={'D'}
CC(ALL(:,2:4)<=60)={'F'}
CC = categorical(CC);
PE = CC(:,1);
EM = CC(:,2);
PS = CC(:,3);
TT = table(ID, PE, EM, PS)
Num_C = sum(CC=='C', 'all')
fprintf('# of low graded students are %d \n', Num_C)
%% Good luck
  3 Kommentare
Image Analyst
Image Analyst am 15 Mai 2021
For Exercise 2A, your counts of 3 for the As and Fs are correct. The exercise is missing the counts for the other grades so you need to add that in.

Melden Sie sich an, um zu kommentieren.


Image Analyst
Image Analyst am 13 Mai 2021
You can either do this by doing a series of comparisons like
numCs = sum(grades > 70 & grades <= 80) % Compute the number of "C" grades.
or you can specify the edges and pass the edges into histogram() or histcounts().
You forgot to show us the way you did it, so we cannot correct your code for you.

DGM
DGM am 13 Mai 2021
Bearbeitet: DGM am 13 Mai 2021
Consider this partial solution for part 2 using some simplifications based on the binning and a basic lookup table. This could be made more robust, but let's just be simple for now.
% make some random test grades
G = randi(40,10,3)+60
sn = 1:10;
examnames = {'basket weaving','daisy picking','alligator wrestling'};
lut = {'F','F','F','F','F','F','D','C','B','A'};
bin = ceil(G/10);
gradeletter = lut(bin);
table(sn',[gradeletter{:,1}]',[gradeletter{:,2}]',[gradeletter{:,3}]', ...
'variablenames',['student id',examnames])
gives
ans =
10×4 table
student id basket weaving daisy picking alligator wrestling
__________ ______________ _____________ ___________________
1 C D A
2 D B C
3 D C A
4 A B A
5 A C B
6 D A D
7 B A A
8 B A A
9 D A B
10 D D B
"Find the number of students with minimum grades" sounds awfully vague do me. Does that mean "minimum passing grade" (i.e. D) or "minimum valid grade" (i.e. F)?
  2 Kommentare
Adam Danz
Adam Danz am 19 Mai 2021
Bearbeitet: Adam Danz am 19 Mai 2021
What is that mean?
Why don't you try to implement those grades into one of the solutions here?
I really don't think this forum shouldn't be used to do people's homework but that's just my opinion.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by