Help! Negative number problem
이전 댓글 표시
Hello everyone! I'm currently trying to get a (one) negative number in a matrix to power to 'S' so for example (-5)^4. I thought brackets would help me, but nevertheless the output is still -1. The code is beneath and everything works, but the -1 stays a negative number. Can somebody help me?
for u = 1:1:m
for k = 2:1:m
f(u,k) = (f(u,k))^S
a = f(u,k)
h = S
end
S = S + 1
end
The input (matrix f) is as follows:
1 1 1 1
-1 0 3 5
-1 0 3 5
-1 0 3 5
And the output that i get (output from the code above, so the new matrix f):
1 1 1 1
-1 0 9 25
-1 0 27 125
-1 0 81 624
as you can see the rest output of the rest is going good, but when it comes to the negative it isnt. Does anybody know what the problem is?
답변 (1개)
Timothy Singowikromo
2018년 3월 24일
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!