Help me about plot and linspace in matlab ?

조회 수: 69 (최근 30일)
Nguyen Trong Nhan
Nguyen Trong Nhan 2013년 12월 25일
댓글: Nguyen Trong Nhan 2013년 12월 25일
for example I plot the graph y = 2/x by plot command :
x = linspace(1,10,100);
y = 2./x;
plot(x,y,'linewidth',4,'color','r')
It run normally and doesn't have error. But now I plot the graph y = (2/x)^3 by plot:
x = linspace(1,10,100);
y = (2./x)^3;
plot(x,y,'linewidth',4,'color','r')
It appear the error : ??? Error using ==> mpower Inputs must be a scalar and a square matrix. Help me fix it. I think I put the dot wrong. thanks very much.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 25일
It should be
x = linspace(1,10,100);
y = (2./x).^3;
plot(x,y,'linewidth',4,'color','r')
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 12월 25일
If x=[1 2 3] , x^3 is not possible, what you need is x.^3, operation element by element
Nguyen Trong Nhan
Nguyen Trong Nhan 2013년 12월 25일
Ok, I see. thanks you very much.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by