フィルターのクリア

How to plot line on graph

2 ビュー (過去 30 日間)
Kong
Kong 2020 年 4 月 10 日
コメント済み: Star Strider 2020 年 4 月 11 日
Hello. I want to plot a curve line.
When I used this, I got the graph.
I want to plot a red curve line without a blue stick. Could I get an idea to fix this code?
for i = 2:30:750
X = csvread('kth_hog2_only.csv');
Y = csvread('kth_hog2_only_class.csv');
X = X(:,1:i);
Mdl = fitcknn(X,Y,'NumNeighbors',3,...
'NSMethod','exhaustive','Distance','cosine',...
'Standardize',1);
rng(1); % For reproducibility
CVKNNMdl = crossval(Mdl, 'KFold', 5);
classAccuracy(i) = 100 - kfoldLoss(CVKNNMdl, 'LossFun', 'ClassifError')*100;
end
plot(classAccuracy)
xlabel('Number of Clusters')
ylabel('CV Sum of Squared Distances')

採用された回答

Star Strider
Star Strider 2020 年 4 月 10 日
Without your data, providing exact code is not possible.
In the interim, try this:
[pks,locs] = findpeaks(classAccuracy);
figure
plot(locs, pks, '-r')
or this:
L = islocalmax(classAccuracy);
x = 1:numel(classAccuracy);
figure
plot(x(L), classAccuracy(L), '-r')
Both should give the same result.
  2 件のコメント
Kong
Kong 2020 年 4 月 10 日
Thank you so much.
I used second method.
Star Strider
Star Strider 2020 年 4 月 11 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by