Array indices must be positive integers or logical values.
Ältere Kommentare anzeigen
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?
Antworten (1)
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.
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
