# new to matlab, can anyone guide me plz?

Printable View

• Sep 11th 2009, 10:14 PM
fearless901
new to matlab, can anyone guide me plz?
hey guys just started matlab class, and need guidance through this homeork problem, lets say i ant function f(x)= x^3 range from 0 to 5 how do i put that into matlab. and am i suppose to put the function show next to the graph into matlab?? thanks alot guys(Bow)
• Sep 12th 2009, 12:12 AM
Roam
Quote:

Originally Posted by fearless901
hey guys just started matlab class, and need guidance through this homeork problem, lets say i ant function f(x)= x^3 range from 0 to 5 how do i put that into matlab. and am i suppose to put the function show next to the graph into matlab?? thanks alot guys(Bow)

You can use this code:

Code:

``` x=[0:1:5]; y=x.^3; plot(x,y)```
line 1: set x-values
line 2: here's your equation -- note the .^ operator
line 3: create the plot

P.S. the .^ operator means raise each element of the array to the power. In your case the array is from 0 to 5 with step size 1 i.e. [1,2,3,4,5]
• Sep 12th 2009, 03:50 AM
CaptainBlack
Quote:

Originally Posted by fearless901
hey guys just started matlab class, and need guidance through this homeork problem, lets say i ant function f(x)= x^3 range from 0 to 5 how do i put that into matlab. and am i suppose to put the function show next to the graph into matlab?? thanks alot guys(Bow)

Define the function it like this:

Code:

`f=@(x) x.^3`
or:

Code:

`f=inline('x.^3')`
then call with:

Code:

```x=0:0.5:5; f(x)```
CB