MATLAB Answers

Using greek letters as variables and as subscript in Matlab

234 views (last 30 days)
F.O
F.O on 23 Nov 2017
Commented: Walter Roberson on 23 Nov 2017
I want to write two things :
  • first B and puttings theta as letter not word as subscripts
  • second : using lambda or others as variables in the function or scriptsphip=phix+asind(cosd(lambda)*sin(D)/cosd(lambdap))

  0 Comments

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 23 Nov 2017
Sorry, the only characters that can be used in variable names or function names are:
  • must start with one of A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z
  • after that, each character must be one of A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, or _ (underscore)
  • maximum of 63 characters in the identifier.
You might want to look at Live Script, which allows you to insert equations and formula as comments and which can be displayed as output.

  2 Comments

F.O
F.O on 23 Nov 2017
This is not practical at all as we need those all the time in physics and mathematics
Walter Roberson
Walter Roberson on 23 Nov 2017
If your system locale is set to English then you can include characters up to char(255) in the source code directly, inside character vectors or string objects or comments.
If your locale is set to some other languages (in particular Korean, Chinese, or Japanese, and possibly others) and your MATLAB is new enough, then you can include characters up to char(65535) in the source code directly, inside character vectors or string objects or comments. But test this before you go very far: if you do not see an option in your File menu to save as UTF-8 then your MATLAB might not support this.
If you are using OS-X then there is a preference hack to enable UTF-8 inside character vectors or string objects or comments; I have never tried using that myself.
However, there is no support for using any characters outside of char(32) to char(126) (together with char(9) [tab], char(10) (newline), and char(13) (carriage return)) in MATLAB source code outside of character vectors or string objects or comments .
I have no information as to whether this will ever change.. eventually, perhaps.
I suggest opening a service request and making your use case known; Mathworks prioritizes changes based upon customer demand in service requests.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products