How to get variable r recognised when inputting a matrice? eg matrix1 = [1, 0; 2/r, 1]
4 views (last 30 days)
Dyuman Joshi on 3 Aug 2022
Use syms to make a symbolic variable (Note - It requires the symbolic math toolbox)
matrix1 = [1, 0; 2/r, 1]
Or if you are going to evaluate the value for some r, a better way would be to define a symbolic function
matrix1(r) = [1, 0; 2/r, 1]
More Answers (1)
Steven Lord on 3 Aug 2022
Another approach, one that doesn't require Symbolic Math Toolbox, is to create a function that you can call with a specific value of r.
M = @(r) [1, 0; 2/r, 1]
This is an anonymous function. To use this anonymous function, call it like you'd call any other function in MATLAB.
A = M(4)
B = M(2)
C = M(1)