How to solve an issue with an equation that has a variable with multiple values.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Javier Solis
le 30 Août 2022
Modifié(e) : Dyuman Joshi
le 13 Sep 2022
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
0 commentaires
Réponse acceptée
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))))
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
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Logical dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!