Machine Learning onramp section 4.6
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Having trouble with the further practice section:
- how can i have the for loop iterate through all the variables in the sampleletters.mat file without creating an array of them manually?
- can i concatenate these results of the new function 'extract' without first creating a table outside of the for loop?
- how do i vertically concatenate outputs of extract? when i use either a semicolon (as shown) or [ ] , i get the error 'all tables being horizontally concatenated must have the same number of rows.'
screenshots of the question and my current work below!
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311747/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/311750/image.png)
0 Kommentare
Antworten (1)
Asvin Kumar
am 10 Jun. 2020
For 2 and 3, have a look at https://www.mathworks.com/help/matlab/matlab_prog/add-and-delete-table-rows.html#AddAndDeleteTableRowsExample-2
Since the outputs of extract are already tables you can concatenate them without creating an empty table.
For 1, you could approach it in a slightly different manner:
T = whos('-file','sampleletters.mat');
BigTable = extract(T(1).name);
for i = 2:size(T,1)
BigTable = [BigTable ; extract(T(i).name)];
end
BigTable
function feat = extract(var_name)
letter = getfield(load('sampleletters.mat',var_name),var_name);
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","NumMinY","AvgU","AvgV","CorrXY"];
feat = table(aratio,numXmin,numYmax,avgdX,avgdY,corrXY,'VariableNames',featurenames);
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!