I want to make a logistical map in Julia and I am having difficulties. I already know how to do it in Octave, how could I turn this code to Julia? My difficulty is mainly in the "map [i,:]" part.
#Creates a vector of initial conditions and "r"
x=rand(150,1);
r=(2.51:.01:4);
#Transpose the r
r=r';
#Makes 300 times the product of each element of r for each element of x
for i=1:300
x=r.*x.*(1-x);
end
#Makes 200 times the product of each element of r for each element of x and stores each value of x on line i of the "map" matrix
for i=1:200
x=r.*x.*(1-x);
map(i,:)=x;
end
#Plots each column of the map for each element o r
plot(r,map,'.')
I haven't written julia in a while so there may be more efficient ways of doing this now, but here is a more or less direct equivalent to your octave code.
using PyPlot
x = rand( 150, 1 );
r = reshape( 2.51:.01:4, (:, 1) );
for i in 1:300
global x
x = r .* x .* (1 .- x);
end
Map = Matrix{Float64}(undef, 200, 150);
for i in 1:200
global x, Map
x = r .* x .* (1 .- x);
Map[i:i,:] .= transpose(x);
end
for i in 1:length(r)
plot( r, Map[i,:], "." )
end