How to raise a decimal numbers as power of A??

조회 수: 11 (최근 30일)
Sabari G
Sabari G 2020년 4월 8일
댓글: Ameer Hamza 2020년 4월 8일
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
Mehmed Saad
Mehmed Saad 2020년 4월 8일
use for loop
Sabari G
Sabari G 2020년 4월 8일
when I use for loop,it takes only one value(i.e i=10) for power. But i need each value starting from 0.1,0.11 upto 10. I hereby attach my code for your reference.

댓글을 달려면 로그인하십시오.

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 4월 8일
편집: Ameer Hamza 2020년 4월 8일
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
Sabari G
Sabari G 2020년 4월 8일
Thank you for your help!!
Ameer Hamza
Ameer Hamza 2020년 4월 8일
Glad to be of help.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stephen23
Stephen23 2020년 4월 8일
편집: Stephen23 2020년 4월 8일
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.

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by