inline.inline at 47

Hello people,
Can someone explain what's kind of error is this:
inline.inline at 47 Input must be a string.
P.S. I use diff function in my code.
Thanks.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Mär. 2012

0 Stimmen

syms x
fun = sym( get(handles.edit4,'String') );
f = matlabFunction(fun, x);
dfun = diff( fun, x );
df = matlabFunction(dfun, x);

Weitere Antworten (1)

Wayne King
Wayne King am 4 Mär. 2012

0 Stimmen

The kind of error you are reporting comes from trying to input a non-string input in inline()
For example:
t = 10;
g = inline(t^2);
Are you trying to do symbolic differentiation?

4 Kommentare

Aldin
Aldin am 4 Mär. 2012
Here is one part of my code:
f = inline(get(handles.edit4,'String'),'x');
y = char(f);
df = inline(diff(y),'x');
Aldin
Aldin am 4 Mär. 2012
It seems to be OK!?
Walter Roberson
Walter Roberson am 4 Mär. 2012
Your "y" is a string. A string is an array of characters. diff(y) applied to an array of anything other than symbolic expressions gives [y(2)-y(1), y(3)-y(2), y(4)-y(3)] and so on.
*Only* symbolic expressions can be differentiated.
Wayne King
Wayne King am 4 Mär. 2012
Hi, No, because diff(y) here is going to return a double-precision vector, which results in the error I showed you above.

Melden Sie sich an, um zu kommentieren.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by