Why program shows Unrecognized function or variable 'g'.
5 views (last 30 days)
Show older comments
Commented: Shuoze Xu on 16 Mar 2022
% legend() function
x = 0:0.5:4*pi;
y = sin(x);
h = cos(x);
w = 1./(1+exp(-x));
% when i run program, it shows that Unrecognized function or variable 'g'.
% while there are g function on mathwork in Two-dimensional line plot module
Andreas Apostolatos on 16 Mar 2022
In the following call of your code snippet,
you are trying to plot variable 'g' against variable 'x' among other, but you never define variable 'g'. You can see this by typing the following command which reveals all variables existing in your Base Workspace,
the output of which in your case is as follows,
Name Size Bytes Class Attributes
h 1x26 208 double
w 1x26 208 double
x 1x26 208 double
y 1x26 208 double
As you can see variable 'g' is nowhere to be seen.
I hope this helps.
More Answers (0)
Find more on 2-D and 3-D Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!