Clear Filters
Clear Filters

how to sum two dimensional variables? and store in a single dimensional variable?

1 view (last 30 days)
R=3;
M=[2,4,8];
beta=8;
pa=9;
pb=7.2;
po=0:0.5:12;
for kk=1:length(M)
for ii=1:length(po)
ko(ii)=floor(po(ii)*M(kk)/pa);
psearch=union([0,pb],(M(kk)*po(ii)/(ko(ii)+1)));
for i=1:1:length(psearch)
pp=(M(kk)*po(ii)-psearch(i))/ko(ii);
f(i)=(1-exp(-((2^R-1)/psearch(i))^(beta/2)))+ko(ii)*(1-exp(-((2^R-1)/pp)^(beta/2)));
end
po_cap=min(f);
if po(ii)>=pa
for i=1:M(kk)
p1i(ii,i)=po(ii);
end
end
if po(ii)< pa
for i=1:M(kk)-ko(ii)-1
p2i(ii,i)=0;
end
for i=M(kk)-ko(ii)
p3i(ii,i)=po_cap;
end
for i=M(kk)-ko(ii)+1:M(kk)
p4i(ii,i)=(M(kk)*po(ii)-po_cap)/ko(ii);
end
end
end
end
I need to sum p1i,p2i,p3i,p4i and store in a variable s1power..how can be done?..can someone
suggest a solution?

Answers (1)

Walter Roberson
Walter Roberson on 2 Apr 2014
sum(p1i(:))

Categories

Find more on Multidimensional Arrays in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!