Why won't my function graph?

2 views (last 30 days)
Ethan Gomez
Ethan Gomez on 4 Dec 2021
Commented: Ethan Gomez on 4 Dec 2021
x = linspace(0,10,100);
y = 3*exp(-x/3)*sin(pi*x);
plot(x, y)
xlabel('Time in Seconds')
ylabel('Voltage over time')

Answers (1)

Benjamin
Benjamin on 4 Dec 2021
You have to use .* (element-wise multiplication) rather than * (matrix multiplication):
y = 3*exp(-x/3).*sin(pi*x);
  1 Comment
Ethan Gomez
Ethan Gomez on 4 Dec 2021
Ahh okay thank you very much

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!