Variable not recognized after program restart
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
So I've been writing some code for a university project, and while I was doing the exact same thing every time I opened my project (open it and when i tried to run it, i added it to the default matlab path). for some reason I get this error:
Undefined function or variable 'x'.
Error in Ex1 (line 4)
df = matlabFunction( diff(f, x) );
My code is this on the first lines:
%Setting of initial functions and variables. Plotting of our function.
h = 10^-6;
f = @(x) 14*x.*exp(x-2) - 12*exp(x-2) - 7*x.^3 + 20*x.^2 - 26*x + 12;
df = matlabFunction( diff(f, x) );
ddf = matlabFunction( diff(df, x) );
...
I believe the code is correct. Besides I have run the code multiple times without a problem!
Do you have any ideas?
0 Commenti
Risposta accettata
madhan ravi
il 6 Gen 2019
Modificato: madhan ravi
il 6 Gen 2019
diff recognises symbolic x but not as a function handle
syms x
h = 10^-6;
f = 14*x.*exp(x-2) - 12*exp(x-2) - 7*x.^3 + 20*x.^2 - 26*x + 12;
df = matlabFunction( diff(f, x) );
ddf = matlabFunction( diff(df, x) );
8 Commenti
Più risposte (0)
Vedere anche
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
