Precedence of operators - which is correct?

I am a beginner and would appreciate your help with this.
I need to code a1.JPG
Which of these 2 MATLAB codes would give me the correct answer?
1) a=24.4*10^-9
2) a=24.4*(10^-9)
I think the operators * and ^ fall under different precedence levels, so I am confused as to which operator would be applied first if I used the 1st line of code.
Thanks

 Réponse acceptée

Image Analyst
Image Analyst le 9 Déc 2018
Modifié(e) : Image Analyst le 9 Déc 2018

0 votes

The raising to a power happens first. The multiplication happens second.
The two equations should give the same value - try it.
It is NOT a=(24.4*10) ^ (-9)
You could also do
a=24.4e-9
and get the same number. The 10^ can be replaced by E or e.

Plus de réponses (0)

Catégories

En savoir plus sur Get Started with MATLAB dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by