what is the problem

조회 수: 1 (최근 30일)
abdullah ali
abdullah ali 2021년 4월 7일
답변: naddin Jr. Julius Peter 2021년 4월 22일
x=0:0.1:6;
fx=exp(x)*sin^2*(x);
plot(x,fx,'linewidth', 1.5)
xlabel('x','fontweight','bold','Fontsize',15)
ylabel('fx','fontweight','bold','Fontsize',15)
set(gca,'fontsize',15)
set(gcf,'color','w')
title('fx vs x')
axis square

채택된 답변

Star Strider
Star Strider 2021년 4월 7일
Two problems, actually.
Use element-wise muultiplication and exponentian operators:
fx=exp(x)*sin^2*(x);
↑ ← HERE
and use the correct call to the sin function and use element-wise exponentiation operator:
fx=exp(x)*sin(x)^2;
↑ ← HERE
producing the correct expression:
fx=exp(x).*sin(x).^2;
See Array vs. Matrix Operations for details. .

추가 답변 (2개)

Alan Stevens
Alan Stevens 2021년 4월 7일
You need to replace fx by
fx=exp(x).*sin(x).^2;

naddin Jr. Julius Peter
naddin Jr. Julius Peter 2021년 4월 22일
x=0:0.1:6;
fx=exp(x)*sin^2*(x);
plot(x,fx,'linewidth', 1.5)
xlabel('x','fontweight','bold','Fontsize',15)
ylabel('fx','fontweight','bold','Fontsize',15)
set(gca,'fontsize',15)
set(gcf,'color','w')
title('fx vs x')
axis square

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by