That is approximately what I was doing in the code above, I think. Toss it in to a single piecewise equation and get numbers out.
Do you have intercepts for those values lines?
If I plot what you just said (without a randomizer), I get this:
That's:
Code:
clear;
cRatio=[0:.01:3]; % Make an array of numbers from 0 to 3 counting by 0.01s.
reso = length(cRatio); % How long is the array?
bigar = zeros(10000,reso); % This is just for lag, although it isn't really necessary here because the array size never changes. Habit.
for index=1:reso % This index variable is for counting through the elements of cRatio
randy = cRatio(index) - rand(10000,1)*3/4; % Makes a 10000 element array of cRatios below the current cRatio with varying 0~3/4 offsets.
for n = 1:10000
if randy(n) <= .5
bigar(n,index) = 9*randy(n)/8; % Equation Below 0.5
else
if randy(n) <= .75
bigar(n,index) = 1; % Equation between .5 and .75
else
if randy(n) <= 1.75
bigar(n,index) = 9*randy(n)/8; % Equation between .75 and 1.75
else
bigar(n,index) = randy(n)+.375; % Equation between 1.75 and 3.0
end
end
end
% These next two steps just apply the floor and ceiling.
if bigar(n,index) < 0
bigar(n,index) = 0;
end
if bigar(n,index) > 3
bigar(n,index) = 3;
end
end
end
% If I wanted to add a randomizer, I could add it here.
plotar = zeros(3,reso);
plotar(1,1:reso) = cRatio; %Cratio!
plotar(2,1:reso) = min(bigar); %Grab the min values
plotar(3,1:reso) = max(bigar); %Grab the max values
figure; plot(cRatio,plotar(2,:)); hold on; plot(cRatio,plotar(3,:)); % Plot the mins, then plot the maxes both against cRatio.
Did you mean to add something to the equations like an intercept? It's pretty obvious that .5*9/8 is not going to be continuous with 1. I've tried to do this though, and I can't get the max and the min both happy at the same time.