0

I wrote this following (written at the end of my question) piece of code which is error-free, but I think, while running it, it has an overwriting problem. During the program, there are two cases where I wanted to draw graphs; first, the graphs of the curves written with ezplot, and second, the plot regression where I wanted to draw regression lines.

When I skip the code plotregression(C_i, D_i), it has no problem displaying the graphs of all five logistic functions (actually one users here showed me the hold on-hold off codes to help doing that), but then, when I incorporate plotregression(C_i, D_i), two things happen:

  1. it shows me all the regression lines, but contrary to having all the regression lines all in the same figure, it keeps changing the regression lines with varying regression coefficients. You can actually see this happening if you run the code.

  2. The effect of plotregression(C_i, D_i) is gone; it no more plots the graphs of the five logistic functions.

I've two questions:

  1. If I want to get two figures, one showing all the five logistic curves, and the other showing all the five regression curves, how can I modify the program minimally so as to get the job done?

  2. How can I stop over writing the regression curves? I used the 'hold on-hold off' in order to avoid the same for the logistic curves, but is it not working on the regression curves?

Here's the code:

syms t;
hold on;


for i=1:5;
P_i=0.009;
r_i=abs(sin(i.^-1));
y_i(t)= P_i*exp(r_i*t)/(1+P_i*(exp(r_i*t)-1));
t_1= 1+rand; t_2= 16+rand; t_3=31+rand;
time_points=[1, t_1; 1, t_2; 1, t_3];
biomarker_values= double([y_i(t_1);y_i(t_2);y_i(t_3)]);
X=vertcat(X,time_points);
Z=blkdiag(Z,time_points);
Y=vertcat(Y,biomarker_values);
G=vertcat(G,[i,i,i]');
ezplot(y_i,[-50,100]); 
C_i=time_points(:,2)
D_i=biomarker_values
plotregression(C_i, D_i)

end;

hold off;

0 Answers0