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

2 次查看(过去 30 天)
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!

回答(1 个)

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

类别

Help CenterFile Exchange 中查找有关 Multicore Processor Targets 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by