Matlab questions from newbies.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Eugene
el 4 de Oct. de 2014
Respondida: John D'Errico
el 4 de Oct. de 2014
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 comentarios
Respuesta aceptada
Mischa Kim
el 4 de Oct. de 2014
Editada: Mischa Kim
el 4 de Oct. de 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;
Más respuestas (2)
John D'Errico
el 4 de Oct. de 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 comentarios
Ver también
Categorías
Más información sobre Develop Apps Using App Designer en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!