How to raise a decimal numbers as power of A??
8 views (last 30 days)
Show older comments
Hello everyone..I am trying to raise decimal values which is ranging from(0.1:0.01:1) to the power of A(3x3 matrix).(eg.. A^[0.1:0.01:1]). I cannot find my answer anywhere.can anyone help me out..Thanks in advance..
4 Comments
Accepted Answer
Ameer Hamza
on 8 Apr 2020
Edited: Ameer Hamza
on 8 Apr 2020
If you want to do the element-wise exponential operation, the following will work on R2016b and onward versions
B = A.^reshape((0:0.1:1),1,1,[]);
For matrix exponentiation
B = arrayfun(@(k) {A^k}, 0:0.1:1)
4 Comments
More Answers (1)
Stephen23
on 8 Apr 2020
Edited: Stephen23
on 8 Apr 2020
Either use a loop or cellfun:
>> A = [1,5,3;4,5,9;7,8,9];
>> V = 0.1:0.11:10;
>> C = arrayfun(@(n)A^n,V,'uni',0);
And checking:
>> C{1} % 1st output
ans =
1.1085 0.27536 + 2.0123e-16i -0.12792 - 1.6129e-16i
-0.081108 - 2.2204e-16i 1.11 + 2.7756e-17i 0.2149 + 6.793e-17i
0.20384 - 1.0408e-17i 0.023577 + 2.2551e-17i 1.2353 - 1.3849e-17i
>> C{2} % 2nd output
ans =
1.1854 0.64417 + 9.7145e-17i -0.25035 - 7.7865e-17i
-0.13946 1.2253 + 2.7756e-17i 0.54956 - 2.2247e-17i
0.50717 - 2.7756e-17i 0.12473 + 1.0408e-17i 1.5344 + 2.9295e-18i
>> C{3} % 3rd output
ans =
1.2109 - 2.2204e-16i 1.0774 + 1.1102e-16i -0.32664 + 1.1886e-18i
-0.13857 - 2.2204e-16i 1.3464 + 5.5511e-17i 1.0074 + 4.5683e-17i
0.90535 0.33962 + 1.3878e-16i 1.8931 - 1.1124e-16i
etc.
See Also
Categories
Find more on Image Processing Toolbox 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!