Borrar filtros
Borrar filtros

I want to simulate linear change, can you help me?

2 visualizaciones (últimos 30 días)
LB
LB el 12 de Oct. de 2016
Respondida: Image Analyst el 12 de Oct. de 2016
Hi,
I am going to simulate data with linear change. I have already done a simple simulation with only a random error-part like this:
-
function simulation1_values=simulation1(h_error,grand_mean,Nu)
rng('shuffle')
grand_mean=74.3;
Nu=72;
simulation1_values=zeros(Nu,1);
Q=length(simulation1_values);
for r=1:Q
simulation1_values(r)=0;
h_error=randn;
simulation1_values(r)=grand_mean+h_error;
end
end
-
Now I want to include a part that gives a linear change from say 74.3 to 90. Can someone help me? :)
Thank you!

Respuestas (1)

Image Analyst
Image Analyst el 12 de Oct. de 2016
Try linspace
startingValue = 74.3; % Whatever you want.
endingValue = 90; % Whatever you want.
numberOfElements = Q; % Whatever you want.
linearValues = linspace(startingValue, endingValue, numberOfElements);

Categorías

Más información sobre Multicore Processor Targets en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by