Matlab questions from newbies.
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
R = 8.31453Jmol-1K-1 in matlab command is it R=8.31453.*J.*(mol^-1).*(K^-1)? Do we need to use the .* in such case?
T = 273.15K means T=273.15*K Am i right?
0 Commenti
Risposta accettata
Mischa Kim
il 4 Ott 2014
Modificato: Mischa Kim
il 4 Ott 2014
Eugene, MATLAB does not know about units and only takes care of the numerics. In other words, you need to make sure that the units in an equation are compatible. E.g., looking at Newton's 2nd law of motion, F = ma: if you are using SI units, mass is given in kg, acceleration in m/s^2, and force in N. If, for example, acceleration is given in cm/s^2 you need to make the conversion (to m/s^2). MATLAB only keeps track of the numeric values of m, a, and F. So in your case (ideal gas law?):
R = 8.31453;
T = 273.15;
Più risposte (2)
John D'Errico
il 4 Ott 2014
A number is just a number, no more than that. As Mischa said, there are no units in MATLAB, unless you use a toolbox that provides them for you. (There is at least one units toolbox on the FEX.)
Only you know that this particular number refers to a temperature in degrees K, as opposed to the speed of light when passing through honey, here maybe measured in giga-furlongs per fortnight.
You other question was about a need to use .*, and the simple rule is, for scalar multiplies, it does not matter. Here your terms are all apparently scalars, not vectors or arrays. So .* will be the same as *, nothing to worry about.
Had you have some of those arguments as vectors or arrays, and you wanted to use an element-wise multiply, then you need to use .* as the operator, as well as .^ and ./ if they too were employed.
It is not a bad idea to just get in the habit of always using .* for your multiplies in these things. That way there will be no mistake, and only use * for when you really need a matrix multiply between matrices and/or vectors. But that is purely personal preference.
0 Commenti
Vedere anche
Categorie
Scopri di più su Develop Apps Using App Designer in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!