function posi = position(m)
m = 10;
N = 400;
h = 0,1;
v_1 = 25;
for i = 1:m
posi(1,m) = (m +1 - i) * 10;
end
for i = 1:N
posi(i+1,1) = posi(i,1) + h * v_1;
end
for j = 2:m
for i = 1:N
posi(i+1,j) = posi(i,j) + h * velo(i,j,posi(i,j-1),posi(i,j));
end
end
end
function veloc = velo(i,j,x,y)
m = 10;
N = 400;
v_1 = 25;
d = 10;
h = 0.1;
for j = 1:m
veloc(1,j+1) = 0;
end
if x - y == d
veloc(i,j) = veloc(i-1,j);
else
veloc(i,j) = veloc(i,j-1) + h * acc(i,j,x,y);
end
function acce = acc(i,j,x,y)
d = 10;
if x - y > d * 2
acce(i,j) = 10;
elseif x - y > d
acce(i,j) = 5;
elseif x - y < d
acce(i,j) = -2;
end
The problem's origin is a system of ODE's.
My idea is to create a N x m - matrix, for each car's position, velocity and acceleration for each euler step. For that I use three different functions. I don't see why this doesnt work.
Unable to perform assignment because the size of the left side is 1-by-1 and the size of the
right side is 1-by-10.
Error in velo (line 22)
veloc(i,j) = veloc(i,j-1) + h * acc(i,j,x,y);
Error in position (line 20)
posi(i+1,j) = posi(i,j) + h * velo(i,j,posi(i,j-1),posi(i,j));
It seems like it's the call to the acceleration function that is lacking something. I wanna keep the variables x,y from the original function. What am I doing wrong?
Any help is muy appriciated! <3
0 Comments
Sign in to comment.