0

不知道我做错了什么。我正在尝试将函数 crazyGrade 的结果用于我的新函数 GradeDist 但我做错了什么。

 function [newGrades]=GradeDist(grades)

 newGrades=crazyGrade(grades) 
 % I want to take GradeDist(grades) 
 %and use the parameter grades to pass through crazyGrade 
 %and return it back to this function...but I cant figure that out...


 end
 % I want to use the output of this function in GradeDist
 function newGrades=crazyGrade(grades)
 newGrades=upper(grades) 
 newGrades(grades=='A')='F'; 
 newGrades(grades=='B')='D';
 newGrades(grades=='C')='C';
 newGrades(grades=='D')='B';
 newGrades(grades=='F')='A';
 newGrades(grades=='Y')='W';
 end

当我将 GradeDist('A') 放在命令行中时。我没有得到任何输出。

4

1 回答 1

0

我认为因为我的文件名是我更改它时的 crazyGrader 函数的名称,所以它似乎有效。如果有人感兴趣,这就是我想做的事情。

function newwGrades=GradeDist(grade)

newwGrades=crazyGrader(grade)



end



function newGrades=crazyGrader(grades)
newGrades=upper(grades) % convert the string to uppercase letter
% so it will be a string.
newGrades(grades=='A')='F';  % index the grades and replace the grades 
% according to the letter.
newGrades(grades=='B')='D';
newGrades(grades=='C')='C';
newGrades(grades=='D')='B';
newGrades(grades=='F')='A';
newGrades(grades=='Y')='W';
end
于 2013-10-03T22:03:40.007 回答