Reputation: 412
I have a data set called curvefit and the following code plot(curvefit,'b-')
When this code is plotted I get this plot image
However when I try to do a subplot with subplot(2,1,1); plot(curvefit,'b-')
I get this (actual subplot code to produce image uses subplot(1,1,1)
to create larger image, result is the same)
I've cleared my workspace of any extraneous variables, used clf beforehand. Hold on
is not on, these plots are plotted seperately. I'm not sure what's going on or how to fix this. Thanks to anybody who can! Here is my code if it helps
figure
set(gcf, 'Position', get(0,'Screensize'));
span=61;
smooth349=smooth(updisplacementP349,span);
subplot(2,1,1); plot(upliftdatesP349,smooth349,'b-')
datetick('x')
curvefit349=fit(upliftdatesP349',smooth349,'sin4');
subplot(2,1,2); plot(curvefit349,'b-');
upliftdatesP349 is a 1 by 3038 row of dates with each date taken per day
updisplacementP349 is a 3038 by 1 vector of data. I'm new to stack overflow so I am not sure what the procedure is on posting exact code because mine pulls data from large text files which I can't post.
Upvotes: 0
Views: 223
Reputation: 1128
Try this, it's not exactly what you are after but you can turn off the other curve.
load hahn1
f = fit( temp, thermex, 'rat23' )
subplot(2,1,1);
h= plot(f,1:size(thermex),thermex);
set(h(1),'Visible','off');
subplot(2,1,2);
h= plot(f,1:size(thermex),thermex);
set(h(2),'Visible','off');
As for your example try this:
subplot(2,1,1);
h= plot(curvefit349,1:size(upliftdatesP349),upliftdatesP349);
set(h(1),'Visible','off');
subplot(2,1,2);
h= plot(curvefit349,1:size(upliftdatesP349),upliftdatesP349);
set(h(2),'Visible','off');
I think your problem could possibly be a bug in Matlab but the workaround above should work fine.
Upvotes: 1