# Math Help - new to matlab, can anyone guide me plz?

1. ## 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

2. 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

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]

3. 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
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