Undefined function error. How to correct ?
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bhagat
am 2 Mär. 2011
Kommentiert: Pankaj Wagh
am 13 Apr. 2021
I am trying to use the expand function. As a simple example i am trying to execute the following code as an m-file.
x=(1-r).^2; y=expand(x);
But it gives the following error: -------- ?? Undefined function or variable 'r'.
Error in ==> test at 1 l=(1-r).^2; ----x----
How to correct this error ??
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 2 Mär. 2011
Start with
syms r
As expand() is part of the symbolic toolkit.
2 Kommentare
Pankaj Wagh
am 13 Apr. 2021
I am facing the same Undefined Error for the raylrnd function. Can you suggest any solution for that?
Weitere Antworten (1)
Matt Fig
am 2 Mär. 2011
It would seem you need to define r. Try putting a WHOS right before the line that errors (or put a break point above that line and query the same way):
whos
x=(1-r).^2;
y=expand(x);
If you don't see an r in the list, you don't have r defined in the scope of the code. This is not a problem of the EXPAND function, but of your not having defined r where the code you are trying to execute can see it.
.
.
.
And why does the error indicate the problem is a line that looks like this:
l=(1-r).^2
but you showed the code as:
x=(1-r).^2
And did you read the help for EXPAND? Does it work with only one input according to the help?
7 Kommentare
Matt Fig
am 2 Mär. 2011
Look at Walter's suggestion:
syms x
expand((1-x)^2)
I bet there is help for the EXPAND function available by typing:
help expand
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!