I am having trouble trying to debug some code (new to MATLAB). I have come across the following line of code:
CC[theta_] := {{Cos[theta],I Sin[theta]},{I Sin[theta], Cos[theta]}}
I get an error stating:
Parse error at ":": Usage may be invalid MATLAB syntax.
When I remove the :, I get the exact same message, just that in this case it says 'Parse error at "="'. Is there any way to fix this? This is fairly old MATLAB code so I'm not sure if the syntax style has changed.
The provided code origins clearly from Mathematica. To do the same in Matlab, we can define a function handle:
1iis the imaginary unit in Matlab (Iin Mathematica). Matlab uses[a,b;c,d]to define a2x2-matrix ({{a,b},{c,d}}in Mathematica). The definition:=is not possible in Matlab. A function handle (as in the example) or a symbolic function can be used.Evaluated at
theta=pi/4with the commandCC(pi/4)gives this result: