Summation in MATLAB in 4 dimenstion
이전 댓글 표시
I have a matrix with 4 dimentions.
I should sum values.
w(i,j,k,t)
k is constant.t is time
My problem is how to add t to loap.
for example for t=1, give me the results but I repeate up to 12. I need sumation for each t seprately and save it and then repeat it for 12 times.
How can do it?
sum=0
for i=1:i
for j=97:176
if w(i,j,15,t)<0
sum=sum+w(i,j,15,t)/(pm(i,j)*pn(i,j))
end
end
end
댓글 수: 1
Walter Roberson
2023년 2월 16일
We advise against using sum as the name of a variable. It is very common for people who use sum as a variable name to find that they also need to call upon the MATLAB sum function. And besides, it confuses the readers.
채택된 답변
추가 답변 (1개)
Fangjun Jiang
2023년 2월 16일
0 개 추천
S = sum(X,DIM) sums along the dimension DIM
댓글 수: 2
JAVAD
2023년 2월 16일
이동: Fangjun Jiang
2023년 2월 16일
Fangjun Jiang
2023년 2월 16일
You need to clarify
- what is "i" in "for i=1:i"
- assume t is 1:12?
- pm? pn?
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!