Do I need symbolic math toolbox to graph a function such as f(x)=ln(x) or f(x, y)=y^2/x

2 views (last 30 days)
I just bought matlab and while processing data works well I cannot find how to graph functions from R to R for instance. Is it the case that I need to buy symbolic math toolbox in order to be able to do these graphings?

Accepted Answer

Stephen23
Stephen23 on 7 Nov 2015
Edited: Stephen23 on 7 Nov 2015
There is no need for the symbolic toolbox for such simple functions. Try this:
>> X = 0:0.1:3;
>> Y = log(X);
>> plot(X,Y)
Or your second example:
>> [X,Y] = meshgrid(0:0.1:2,1:5);
>> Z = Y.^2./X;
>> surf(X,Y,Z)
  3 Comments
Stephen23
Stephen23 on 7 Nov 2015
Edited: Stephen23 on 8 Nov 2015
You pick those numbers to suit your needs: what range do you want to plot, and with how many points? The introductory tutorials describe how to make vectors of values:
And for more detailed info:
Tip use your favorite internet search engine to search the MATLAB documentation. Half of the questions we answer here are solved by simply reading the documentation.
Walter Roberson
Walter Roberson on 8 Nov 2015
Additionally:
If you had an expression in symbolic form because you were using the Symbolic toolbox, then you would still need to select particular ranges to plot it over. The plot routines cannot plot symbolic expressions directly: they can only plot the results of substituting in particular values into symbolic expressions and by so doing getting a numeric result.
You may also wish to look at ezplot()

Sign in to comment.

More Answers (1)

John BG
John BG on 10 Mar 2017
Hi Emilia
if it's about just plotting a function, there is a new function that does not require the symbolic Tool box called fplot
fplot(@(x) log10(x))
.
the same applies to fsurf, no need for the previous mesh declaration
fsurf(@(x,y) sin(x)+cos(y),'lines','none')
.
'
the field lines=none is optional
mesh also has a new fmesh
if you find this answer useful would you please be so kind to mark my answer as Accepted Answer?
To any other reader, please if you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John BG

Products

Community Treasure Hunt

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

Start Hunting!