Getting the same incorrect plot with exponential function

3 Ansichten (letzte 30 Tage)
Mohamed Aziz Elouaer
Mohamed Aziz Elouaer am 11 Okt. 2021
Beantwortet: Walter Roberson am 11 Okt. 2021
I need to plot this function:
y= e^(2x)-3*e(x)
But matlab keeps showing me the incorrect plot, I mean the same incorrect one even if I change the function.

Antworten (2)

Image Analyst
Image Analyst am 11 Okt. 2021
That is the correct plot for that equation. What were you expecting? Why do you say it's wrong?
x = linspace(0, 10, 1000);
y = exp(2 * x) - 3 * exp(x);
plot(x, y, 'b-', 'LineWidth', 2);
grid on;
xlabel('x', 'FontSize', 18)
ylabel('y', 'FontSize', 18)
And if I change the equation, the plot looks different.

Walter Roberson
Walter Roberson am 11 Okt. 2021
y = @(x) exp(2*x)-3*exp(x)
y = function_handle with value:
@(x)exp(2*x)-3*exp(x)
exp(2*10)
ans = 4.8517e+08
fplot(y, [-2 10])
Looks correct to me. You are asking to plot up to

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by