필터 지우기
필터 지우기

how to write a formula in matlab?

조회 수: 2 (최근 30일)
Vika
Vika 2023년 9월 16일
답변: Walter Roberson 2023년 9월 16일
  댓글 수: 1
Image Analyst
Image Analyst 2023년 9월 16일
Not sure what you mean. Do you want to write that formula to the command window or onto an axes or image? Or do you have all those variables and want to carry out the operations (like log, squaring, differentiation, etc.)?

댓글을 달려면 로그인하십시오.

답변 (1개)

Walter Roberson
Walter Roberson 2023년 9월 16일
Use the Symbolic toolbox. Declare symbolic variable names with syms such as
syms h_I T_0 t z
MATLAB has no implicit multiplication at all. For the purpose of this formula, use the .* (dot asterisk) operator for every multiplication.
Use log for ln
In MATLAB, {} has nothing at all to do with grouping or precedence: use () instead of {} for those. You will get errors if you use {}
In MATLAB, [] is for creating vectors and arrays, not for grouping or precedence. Use () instead of [] for those. If you use [] you might get the results you want, but you would have to be careful about the spacing. For example, in MATLAB (A -1) is always "subtract 1 from A" but [A -1] means to try to create a row vector with the elements of A followed by the scalar negative-one. It is best to avoid using [] for grouping or precedence.
In MATLAB, a function name such as log followed by an expression in () is a request to invoke the function on the parameters listed inside the () expression. In MATLAB, a function name such as log followed by an [] expression is typically going to result in a syntax error, but from time to time depending on the exact function and the spacing being used, might simply give you an unexpected result. Do not try to use [] for function parameters in MATLAB.
When using the symbolic toolbox, for differentiation see diff
Note that taking the partial derivative of T_0 with respect to t implies that T_0 is a function of at least one variable. You would need to declare it with syms such as
syms T_0(t, z)
If is intended to represent derivative of s then that implies s is a function, and you would need to declare it, such as
syms s(t)
s_prime = diff(s)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by