Having error 'Invalid array indexing'. Please help me to solve this issue
Mostrar comentarios más antiguos
% Solve using Euler method
for i = 1:num_steps
v1_euler(i+1) = v1_euler(i) + dt * f(t(i), v1_euler(i), v2_euler(i))(1);
v2_euler(i+1) = v2_euler(i) + dt * f(t(i), v1_euler(i), v2_euler(i))(2);
Respuestas (1)
Image Analyst
el 23 de Jun. de 2023
What is f? If f is a function you can't do this:
f(t(i), v1_euler(i), v2_euler(i))(1)
You'd need to get the results (returned vector) from f, then do f(1)
for example
result = f(t(i), v1_euler(i), v2_euler(i)); % Get result vector out of "f" function.
v1_euler(i+1) = v1_euler(i) + dt *result(1);
Categorías
Más información sobre Programming en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!