Having error 'Invalid array indexing'. Please help me to solve this issue
이전 댓글 표시
% 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);
답변 (1개)
Image Analyst
2023년 6월 23일
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);
카테고리
도움말 센터 및 File Exchange에서 Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!