How to solve an issue with an equation that has a variable with multiple values.

1 vue (au cours des 30 derniers jours)
I have this equation
𝑦 = 𝑒^(3𝑥)(2𝑥+𝑙𝑛(40𝑥))
and have to solve y using the values x:[1,2,3,4,5,6,7,8,9,10]
I currently have this as my code, but I keep getting wrong values for y. I am just wondering where I went wrong.
x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
y = (exp(3*x).*((2*x)+(log(40*x))))
here are my results
y =
1.0e+14 *
0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0003 0.0058 0.1271 2.7776

Réponse acceptée

Dyuman Joshi
Dyuman Joshi le 30 Août 2022
Modifié(e) : Dyuman Joshi le 13 Sep 2022
You are not getting wrong values of y.
format long
x = (1:10)';
y = (exp(3*x).*((2*x)+(log(40*x))))
y = 10×1
1.0e+14 * 0.000000000001143 0.000000000033816 0.000000000874120 0.000000021280472 0.000000500104652 0.000011477782122 0.000258946694719 0.005766237134192 0.127085596247646 2.777571252192637
Since there is a big difference in the first value and the last value of the expression, and when presented in short format (the default format), the answer is displayed with (first) 4 (rounded) digits in exponent/scientific notation
When some of the values in an array are short numbers and some have large exponents (as is your case), you can use long format as shown above or shortG as shown below
format shortG
y
y = 10×1
1.0e+00 * 114.26 3381.6 87412 2.128e+06 5.001e+07 1.1478e+09 2.5895e+10 5.7662e+11 1.2709e+13 2.7776e+14

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by