what is the problem

1 次查看(过去 30 天)
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
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