Array indices must be positive integers or logical values.
조회 수: 2 (최근 30일)
이전 댓글 표시
g=9.81;
m=95;
v=25;
t=10;
f(x)=m*g/x*(1-exp(-(x/m)*t));
Array indices must be positive integers or logical values.
I am taking this message. What is wrong at the code?
댓글 수: 2
답변 (1개)
Star Strider
2021년 5월 12일
That notation only will work in the Symbolic Math Toolbox. Use Anonymous Functions to create functions for numeric calculations outside the Symbolic Math Toolbox.
Perhaps —
g=9.81;
m=95;
v=25;
t=10;
f = @(x) m*g./x.*(1-exp(-(x/m)*t));
xval = 10;
x = fzero(@(x)f(x)-xval,100)
xv = linspace(-1,150);
figure
plot(xv,f(xv), x, xval,'rs')
The function will not cross the x-axis. It is possible to determine where it will reach a specific value.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Calculus에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!