How to create a new matrix from an function performed on another matrix?
1 view (last 30 days)
Show older comments
Hi, say I have a 5x1 matrix of complex numbers
V=[1+0i;
3+4i;
2+3i;
0;
4+3i];
And I wish to create a new 5x1 matrix "Theta" that has the angles of each element in it.
I was able to come up with:
Theta = [rad2deg(angle(V(1,1)));rad2deg(angle(V(2,1)));rad2deg(angle(V(3,1)));rad2deg(angle(V(4,1)));rad2deg(angle(V(5,1)));];
but Im wondering if theres a more straightforward, compact way to do it. I tried with arrayfun but I couldn't get it to work
Thank you
0 Comments
Accepted Answer
Dave B
on 27 Aug 2021
Many functions in MATLAB will just accept a matrix:
V=[1+0i; 3+4i; 2+3i; 0; 4+3i];
Theta = rad2deg(angle(V))
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!