簡體   English   中英

MATLAB將函數輸出轉換為另一個函數

[英]MATLAB using output of function into another function

不知道我在做什么錯。 我正在嘗試將函數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')時。 我沒有任何輸出。

我認為是因為我的文件名是當我更改它時的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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM