Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
利用MATLAB将函数的输出转换成另一个函数_Matlab_Function_Nested - Fatal编程技术网

利用MATLAB将函数的输出转换成另一个函数

利用MATLAB将函数的输出转换成另一个函数,matlab,function,nested,Matlab,Function,Nested,不知道我做错了什么。我试图将函数疯狂升级的结果应用到我的新函数等级中,但我做错了什么 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..

不知道我做错了什么。我试图将函数疯狂升级的结果应用到我的新函数等级中,但我做错了什么

 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')时。我没有得到任何输出。

我想是因为我的文件名是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

是字符串(数组)/单元格数组吗?请发布错误消息,否则很难推断出错误。这并不明显。还包括输入data@AndreasH. 当我在命令行中输入GradeDist('A')时。我没有得到任何输出。当我输入它时,我得到了一些东西(不幸的是,换行符没有正确显示):>>GradeDist('A')newGrades=A newGrades=F ans=FAlso请注意,由于newGrades(grades='A')='F',你永远不会得到“F”;新等级(等级='F')='A';;-)