what is the problem

1 visualización (últimos 30 días)
abdullah ali
abdullah ali el 7 de Abr. de 2021
Respondida: naddin Jr. Julius Peter el 22 de Abr. de 2021
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

Respuesta aceptada

Star Strider
Star Strider el 7 de Abr. de 2021
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. .

Más respuestas (2)

Alan Stevens
Alan Stevens el 7 de Abr. de 2021
You need to replace fx by
fx=exp(x).*sin(x).^2;

naddin Jr. Julius Peter
naddin Jr. Julius Peter el 22 de Abr. de 2021
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

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by