Adding a linear line of best fit to subplots
조회 수: 4 (최근 30일)
이전 댓글 표시
I have been looking up matlab help on this but I cant seem to get my head around it. For example when I look at my code I just have:
plot (SigVal)
So when I try and plot:
polyval(x, y 1)
I have nothing to put between these brackets except "SigVal". Can someone talk me through how I go about adding a line of best fit to this subplot?
thanks
%-------------------------------------- SIG VAL SUBPLOT -------------------
figure('name','resultimage');
Len=1400;
Wid=600;
aa=25;
bb=200;
set(gcf,'position',[aa bb Len Wid]);
subplot(2,3,1)
xmin=1;
xmax=100;
plot(SigVal)
h=plot(SigVal);
% label max and min values of a 'fn1' on the plot
xValue = get(h,'XData');
yValue = get(h,'YData');
imin = find(min(yValue)==yValue);% find the index for the min and max
imax = find(max(yValue)==yValue);% values of yValue
(yValue(imax));
(yValue(imin));
% label the max. and min. values on the plot
ymax=yValue(imax)+3;
ymin=yValue(imin)-3;
y1=ymax-1;
y2=y1;
y3=ymin+1;
maxstr=['max.=',num2str(yValue(imax))];
minstr=['min.=',num2str(yValue(imin))];
text(10, y1, maxstr);
text(50, y2, minstr);
if Signalstabilitytestfail == 1;
Test_resultstr = 'Test FAILED';
text(30, y3, Test_resultstr)
sigvalteststr='fail';
else
Test_resultstr = 'Test passed';
text(30, y3, Test_resultstr)
sigvalteststr='pass';
%warndlg('Signal Stability failed','!! Warning !!')
end
axis([xmin xmax ymin ymax])
title('SigVal')
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!