MATLAB Answers

How to plot a function with a matrix?

38 views (last 30 days)
Bart on 12 Nov 2014
Commented: Star Strider on 12 Nov 2014
For an exercise at school, I'm trying to plot a function where the variable is a matrix. The function is very simple: y=x^4 The matrix, x, is 0:0.01:20 so it has a range from 0 to 20, and there are 2000 between them. My problem is, the scale of the x-axis is 0-2000, and not 0-20 as i'd suppose it to be. According to the current graph: 1000^4=10000, while it should be: 10^4=10000. What am I doing wrong?


Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 12 Nov 2014
I suspect you’re just plotting y, not x as well. It’s always a good idea to plot both your independent and dependent variables in order to understand your data.
See if this produces the plot you want:
x = 0:0.01:20;
y = x.^4;
plot(x, y)


Bart on 12 Nov 2014
That was just what i needed, thankyou!

Sign in to comment.

More Answers (0)

Sign in to answer this question.