trend line not drawing in sub-plot
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I have this really strange issue going and it is really confusing me. I am trying to plot a trend line through a set of data and I can do it just fine in a regular plot, but as soon as I add it to a sub-plot, I can get either the data or the trend line and not both.
I did try to do it with the toolbox but in a subplot figure, I can only get 1 trend line to show up on any of my 5 subplots at a given time. so both methods are 'either or' and not both :(
any help would be greatly appreciated. thanx.
here is my code i am testing with.
a = [1 2 3 4 5]';
b = [3 7 9 3 7]';
figure
hold all
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
figure
subplot(2,1,1)
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
0 commentaires
Réponse acceptée
Sean de Wolski
le 24 Avr 2012
You need to hold on to your subplot!
figure
subplot(2,1,1)
hold on
plot (a,b);
% plot trend line
f = fittype('a*x+b'); %define fittype
fitobj = fit(a,b,f); %fit line to data
plot (fitobj,'k') %plot trend line
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Fit Postprocessing dans Help Center et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!