Array indices must be positive integers or logical values.

조회 수: 2 (최근 30일)
Dilsah Bahçeci
Dilsah Bahçeci 2021년 5월 12일
답변: Star Strider 2021년 5월 12일
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
Stephen23
Stephen23 2021년 5월 12일
편집: Stephen23 2021년 5월 12일
Most likely x is not a positive integer. What is the value of x ?
Are you actually trying to define a function of the independent variable x ?
Dilsah Bahçeci
Dilsah Bahçeci 2021년 5월 12일
ı am gonna find x by using fzero function. How can ı correct in your opinion?

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
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)
x = 93.1899
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.

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by