필터 지우기
필터 지우기

Wrong equastion of XY dependence

조회 수: 1 (최근 30일)
Pavol Namer
Pavol Namer 2014년 8월 7일
댓글: Pavol Namer 2014년 8월 7일
Hi I try to solve following problem.
I try to type following equastion of XY dependence:
x= [-5,15]
a= 1
b= 12
c= 2.4
r= 1
y= -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2))
figure
plot (x,y)
it should be this equation:
And it should have this shape of XY dependence
But it give me the wrong shape (like linear XY dependence).
Can anybody advise, where the mistake i?
Thank you
P.

채택된 답변

Mischa Kim
Mischa Kim 2014년 8월 7일
편집: Mischa Kim 2014년 8월 7일
Use,
x = -5:0.1:15; % create a vector x, element spacing: 0.1
a = 1;
b = 12;
c = 2.4;
r = 1;
y = -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2));
figure
plot(x,y)
The only difference is in the first line. In your code you evaluate y only twice, at x = -5 and at x = 15.
  댓글 수: 1
Pavol Namer
Pavol Namer 2014년 8월 7일
Oh my got :) Thanks a lot, I am totaly stupid guy :))

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

추가 답변 (1개)

David Sanchez
David Sanchez 2014년 8월 7일
Instead of your definition of x, try the folowing one:
x= -5:.01:15; % array of 2001 elements, your definition were a mere 2 element array
a= 1;
b= 12;
c= 2.4;
r= 1;
y= -1*(a-b*(((x)-r)).^4).*(exp(-1*c*((x)-r).^2));
figure
plot (x,y)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by