I want to simulate linear change, can you help me?
2 views (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
Image Analyst
on 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);
0 Comments
See Also
Categories
Find more on Multicore Processor Targets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!