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
Timothy Singowikromo 2018년 3월 24일

0 개 추천

Ahh! I have found my problem haha... the parameters where wrong
for u = 2:1:m
for k = 1:1:m
f(u,k) = (f(u,k))^S
a = f(u,k)
h = S
end
S = S + 1
end

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2018년 3월 24일

답변:

2018년 3월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by