How to plot a cfit object in the borders of the original data

Hi,
for me it's important to compare many cfit objects, and therefore it is also important where they start and where they begin. Is there a way to define the cfit object only in the borders of the input data?
If not, how can i plot the cfit only in the borders? I will write a code for that instead.
I hope you can help me :)
I already tried
if true
% code
for p=1:anzFigFreq;
E1=plot (curves{p,XX}(-0.2:0));
xlim([0,0.5]);
ylim([-0.5,0]);
set(E1,'Color',Colour(p,:),'DisplayName',[Uebersicht{p*laengeReihe,2} '' Uebersicht{p*laengeReihe,3}]);
legend('-DynamicLegend');
hold all;
end
end
but in that case, nothing except for the legend is plotted.

Answers (1)

Rather than using plot(cfitobj,...), evaluate the cfit objects on the data range you care about:
xr = x(x>xmin & x<xmax);
y1 = cfit1(xr);
y2 = cfit2(xr);
plot(xr,y1,xr,y2)

2 Comments

I don't get it. what is x? i want to plot ,lets say between 5 and 6.
if true
% code
xr=x(x>5 & x<6);
end
this gives me, for sure, undefined function or variable 'x'
and are cfit1 and cfit2 my curve objects?
so can i use
if true
% code
y1=curves{p,XX}(xr);
end
?
I thought i have the answer, because i had an array from xmin to xmax. but now, if i use your suggestion, all i get is the original data, not the regression plotted!?
if true
% code
uebersichtzaehler=0;
for p=1:anzFigFreq;
hilfe1=Datenbank(XX,:);
x_bereich_regression=hilfe1(2*uebersichtzaehler+1:2:(p*laengeReihe*2));
y_bereich_regression=curves{p,XX}(x_bereich_regression);
E1=plot (x_bereich_regression,y_bereich_regression);
set(E1,'Color',Colour(p,:),'DisplayName',[Uebersicht{p*laengeReihe,2} '' Uebersicht{p*laengeReihe,3}]);
legend('-DynamicLegend');
hold all;
uebersichtzaehler=uebersichtzaehler+laengeReihe;
end
so now x_bereich_regression is the array from xmin to xmax and at the end, y_bereich_regression gives back the original y data i used to create curves{p,XX} with, which should be a cfit object..
I'm desperate for help! :(

Sign in to comment.

Categories

Asked:

on 4 Nov 2014

Commented:

on 5 Nov 2014

Community Treasure Hunt

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

Start Hunting!