Idk why Cell contents reference from a non-cell array object in my file
Afficher commentaires plus anciens
How do i fix: Cell contents reference from a non-cell array object.
Error in RKSystems (line 27) k(1, j) = h*f{j}(t, w);
%
function RKSystems(N)
%N = iterations
%m is the vector size
m=4;
h = 10^-2; %step size
t = 0; %time start
v = 1000; %initial velocity
theta = pi/4; %angle of launch
%f is the ODE vector
%What do i need to put for 'y1' part? w(3)?
f= @(t,x) [ x(2); -.02*(x(2)/(1+x(3)/2000)); x(4); -.05*x(4)/(1+x(3)/2000) - 9.8;];
w = zeros(1, m);
w(1,:) = [0, v*cos(theta), 0, v*sin(theta);]; %initial condition row vector
fprintf('t = %.2f;', t);
for i = 1:m
fprintf(' w(%d) = %.10f;', i, w(i));
end
fprintf('\n');
k = zeros(4, m);
for i = 1:N
for j = 1:m
k(1, j) = h*f{j}(t, w);
end
for j = 1:m
k(2, j) = h*f{j}(t + h/2, w + (1/2)*k(1, :));
end
for j = 1:m
k(3, j) = h*f{j}(t + h/2, w + (1/2)*k(2, :));
end
for j = 1:m
k(4, j) = h*f{j}(t + h, w + k(3, :));
end
for j = 1:m
w(j) = w(j) + (k(1, j) + 2*k(2, j) + 2*k(3, j) + k(4, j))/6;
end
t = a + i*h;
fprintf('t = %.2f;', t);
for k = 1:m
fprintf(' w(%d) = %.10f;', k, w(k));
end
fprintf('\n');
end
end
Réponses (0)
Catégories
En savoir plus sur Vehicle Dynamics Blockset dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!