Matlab questions from newbies.

2 ビュー (過去 30 日間)
Eugene
Eugene 2014 年 10 月 4 日
回答済み: John D'Errico 2014 年 10 月 4 日
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?

採用された回答

Mischa Kim
Mischa Kim 2014 年 10 月 4 日
編集済み: Mischa Kim 2014 年 10 月 4 日
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;
  1 件のコメント
Eugene
Eugene 2014 年 10 月 4 日
Yes i understand what u mean. Thanks you for your help!

サインインしてコメントする。

その他の回答 (2 件)

per isakson
per isakson 2014 年 10 月 4 日

John D'Errico
John D'Errico 2014 年 10 月 4 日
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.

カテゴリ

Help Center および File ExchangeDevelop Apps Using App Designer についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by