Matlab questions from newbies.
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
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;
추가 답변 (2개)
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.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Develop Apps Using App Designer에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!