How to index and replace
이전 댓글 표시
Hello,
I am trying to learn MATLAB and decided to use the MIT course to look at the slides and I figure the homework would be challenging so I decided to do that as well. I am stuck on problem 9.G.iii. Can someone please assist me.
Here is my code
clear all, close all, clc
%b
load classGrades
%c
namesAndGrades
%d
grades = namesAndGrades(:,2:end)
%e
meanGrades = nanmean(grades(:,1))
for i = 1:7
meanGrades(i,:) = nanmean(grades(:,i))
end
[gradesRows, gradesCol] = size(grades)
%f
for i = 1:15
meanMatrix(i,:) = meanGrades
end
curvedGrades = 3.5*(grades./meanMatrix)
checkCurvedGrades = nanmean(curvedGrades);
%f.iv
curvedGrades5 = find(curvedGrades > 5)
for i = curvedGrades5
curvedGrades(i) = 5
end
checkCurve = find(curvedGrades == 5)
tf = isequal(curvedGrades5,checkCurve)
%g
totalGrade = nanmean(curvedGrades')
totalGrade = ceil(totalGrade)
letters = ['F','D','C','B','A'];
findF = find(totalGrade ==1);
findD = find(totalGrade ==2);
findC = find(totalGrade ==3);
findB = find(totalGrade ==4);
findA = find(totalGrade ==5);
채택된 답변
추가 답변 (1개)
카테고리
도움말 센터 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!