Error in plot function

조회 수: 9 (최근 30일)
Hassan Ashraf
Hassan Ashraf 2019년 9월 19일
댓글: Hassan Ashraf 2019년 9월 20일
Hi I am plotting some results but getting an error in Plot Function. I am using MATLAB 2018b, below is my code
load MCAsLDA
MCAsLDA = table2array(MCAsLDA);
WindowSizes=MCAsLDA(:,1);
Data1Disjoint=MCAsLDA(:,2);
% Data1Disjoint=smooth(Data1Disjoint);
Data1Overlap=MCAsLDA(:,3);
% Data1Overlap=smooth(Data1Overlap);
Data2Disjoint=MCAsLDA(:,4);
% Data2Disjoint=smooth(Data2Disjoint);
Data2Overlap=MCAsLDA(:,5);
% Data2Overlap=smooth(Data2Overlap);
Data3Disjoint=MCAsLDA(:,6);
% Data3Disjoint=smooth(Data3Disjoint);
Data3Overlap=MCAsLDA(:,7);
f1=fit(WindowSizes,Data1Disjoint,'cubicinterp');
f2=fit(WindowSizes,Data2Disjoint,'cubicinterp');
f3=fit(WindowSizes,Data3Disjoint,'cubicinterp');
f4=fit(WindowSizes,Data1Overlap,'cubicinterp');
f5=fit(WindowSizes,Data2Overlap,'cubicinterp');
f6=fit(WindowSizes,Data3Overlap,'cubicinterp');
figure
hold on
p1=plot(f1,WindowSizes,Data1Disjoint,'LineWidth',2);
p2=plot(f2,WindowSizes,Data2Disjoint);
p3=plot(f3,WindowSizes,Data3Disjoint);
p4=plot(f4,WindowSizes,Data1Overlap);
p5=plot(f5,WindowSizes,Data2Overlap);
p6=plot(f6,WindowSizes,Data3Overlap);
grid on
title('Classification accuracy Vs. Window Sizes for LDA')
ylabel('Mean Classification Accuracy')
  댓글 수: 1
Adam Danz
Adam Danz 2019년 9월 19일
Always specify the entire error message.
The logical indices contain a true value outside of the
array bounds.
Error in cfit/plot (line 226)
handles =
plot(xpoints(~outliers),ypoints(~outliers),S2,...
Error in jff (line 26)
p1=plot(f1,[WindowSizes,Data1Disjoint],'LineWidth',2);

댓글을 달려면 로그인하십시오.

채택된 답변

Adam Danz
Adam Danz 2019년 9월 19일
편집: Adam Danz 2019년 9월 19일
Remove the 'LineWidth' name-value pair and specify it after plotting.
p1=plot(f1,WindowSizes,Data1Disjoint);
set(p1,'LineWidth', 2, 'MarkerSize', 25)
If you want to change the properties for all objects,
p(1,:)=plot(f1,WindowSizes,Data1Disjoint);
p(2,:)=plot(f2,WindowSizes,Data2Disjoint);
p(3,:)=plot(f3,WindowSizes,Data3Disjoint);
p(4,:)=plot(f4,WindowSizes,Data1Overlap);
p(5,:)=plot(f5,WindowSizes,Data2Overlap);
p(6,:)=plot(f6,WindowSizes,Data3Overlap);
set(p, 'LineWidth', 2, 'MarkerSize', 20)
Set different colors for each line
set(p(:,2), {'Color'}, mat2cell(jet(size(p,1)),ones(size(p,1),1),3))
Clean up the legend
set(p(:,2), {'DisplayName'}, strcat('fit #',strsplit(num2str(1:size(p,1))))')
legend(p(:,2))
Final result
190919 084706-Figure 1.png
  댓글 수: 1
Hassan Ashraf
Hassan Ashraf 2019년 9월 20일
Thank you :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by