Effacer les filtres
Effacer les filtres

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

2 vues (au cours des 30 derniers jours)
LB
LB le 12 Oct 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!

Réponses (1)

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

Catégories

En savoir plus sur Multicore Processor Targets dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by