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?

 채택된 답변

Star Strider
Star Strider 2014년 11월 12일

0 개 추천

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;
figure(1)
plot(x, y)
grid

댓글 수: 2

Bart
Bart 2014년 11월 12일
That was just what i needed, thankyou!
Star Strider
Star Strider 2014년 11월 12일
My pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

질문:

2014년 11월 12일

댓글:

2014년 11월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by