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 个)
类别
在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!