How to solve a task within Machine Learning Onramp Course?

24 次查看(过去 30 天)
Hello everyone
I hope to get help regarding the following inquiry:
I am doing the Machine Learning Onramp Course. Currently I am in the section: Engineering Features Automate Feature Extraction (Create a Feature Extraction Function).
I am following the next instruction to complete the task:
load sampleletters.mat
letter = b1;
aratio = range(letter.Y)/range(letter.X)
idxmin = islocalmin(letter.X,"MinProminence",0.1);
numXmin = nnz(idxmin)
idxmax = islocalmax(letter.Y,"MinProminence",0.1);
numYmax = nnz(idxmax)
dT = diff(letter.Time);
dXdT = diff(letter.X)./dT;
dYdT = diff(letter.Y)./dT;
avgdX = mean(dXdT,"omitnan")
avgdY = mean(dYdT,"omitnan")
corrXY = corr(letter.X,letter.Y,"rows","complete")
featurenames = ["AspectRatio","NumMinX","NumMaxY","AvgU","AvgV","CorrXY"];
Task 1
Make a table from the features stored in the variables aratio, numXmin, numYmax, avgdX, avgdY, and corrXY by using the table function. Store the result in a variable named feat.
feat = table(aratio,numXmin,numYmax,avgdX,avgdY,corrXY,'VariableNames',featurenames)
Task 2
Recreate the table of features feat, but with the table variable names from the array featurenames.
feat = table(aratio,numXmin,numYmax,avgdX,avgdY,corrXY,'VariableNames',featurenames)
Task 3
At the end of the script, add a local function named extract that takes a single variable, letter, as input and returns a table of features, feat, as output. Copy the code from the beginning of the script, from after letter = b1 to Task 1, and from Task 2 to make the body of the function. Test your function by calling it with b2 as input. Store the result in a variable named featB2.
featB2 = extract(b2)
I got the error
Error using extract (line 6)
Not enough input arguments.
I will really appreciate your cooperation.

采纳的回答

Walter Roberson
Walter Roberson 2024-11-2,21:37
You did not add a local function named extract to your file. A "local function" is one that is placed at the end of your code, starting with the keyword function . (In most cases, you also need an end statement corresponding to the function keyword)
With you not having added a local function named extract to your code, your code was accidentally invoking the MATLAB extract function.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Project File Management 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by