Question

I would like to add Gaussian noise Model with variable Standard Deviation (Sigma) and Variable Mean (Mu) to my Output Curve which is shown in the figure below

http://i.imgur.com/hABfsiC.jpg

Following function generates the Output curve expressed in the figure above

function c_t = output_function_constrainedK2(t, a1, a2, a3,b1,b2,b3,td, tmax,k1,k2,k3)

K_1   = (k1*k2)/(k2+k3);
K_2   = (k1*k3)/(k2+k3);
DV_free= k1/(k2+k3);


c_t = zeros(size(t));

ind = (t > td) & (t < tmax);


c_t(ind)= conv(((t(ind) - td) ./ (tmax - td) * (a1 + a2 + a3)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');


ind = (t >= tmax);


c_t(ind)= conv((a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');



plot(t,c_t);
axis([0 50  0 1400]);
xlabel('Time[mins]');
ylabel('concentration [Mbq]');
title('Model :Constrained K2');
end

The output values for the above function are

 output_function_constrainedK2(0:0.1:50,2501,18500,65000,0.5,0.7,0.3,...
 0.28,0.9,0.014,0.051,0.07)

Now i would like to add the Gaussian probability distribution function with variable Standard deviation Sigma and mean to the above function, could any one please help me through this , I am an absolute beginner to matlab

Était-ce utile?

La solution

between these lines

c_t(ind)= conv((a1 * exp(-b1 * (t(ind) - tmax))+ a2 * exp(-b2 * (t(ind) - tmax))) + a3 * exp(-b3 * (t(ind) - tmax)),(K_1*exp(-(k2+k3)*t(ind)+K_2)),'same');

plot(t,c_t);

add the following

c_t = c_t + normrnd(mu,sigma,length(c_t),1)

refer to the normrnd documentation for more information about the normrnd function. Or type

help normrnd

in the matlab console.

edit to correct this answer according to your last comment:

leave c_t as before, and you will have to create a new vector:

c_t_noise = c_t + normrnd(mu,sigma,1,length(c_t))

also changed the order of parameteres in normrnd to fit your dimension. to plot the two curves, just use the extended plot, like this:

plot(t,c_t, t,c_t_noise)

or do a hold on like this

plot(t,c_t)
hold on %tells matlab to put plots in the same figure
plot(t,c_t_noise)
hold off %this line if you pretend to make some other plot, desactivate hold on

more info about "hold" function in matlab console

help hold
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top