Calculate the summation of matrices within a cell

조회 수: 1 (최근 30일)
George
George 2014년 11월 19일
Hello
I know this is an easy question but I am a bit stuck
I have generate a set of data which I am storing into structures. Then I calculate a quantity over them. My problem is two parted, first i tried to save them into a new structure but it did not allow me, so I stored them into a cell array (which worked perfectly)
In the next loop want to calculate the summation of the available matrices inside the array for a given {n}
field_names = fields(HsD1); %structure field_names2 = fields(TpD1); %structure
for n=1:11%size(field_names2)
pause(0.01)
P=([])
fn2=char(field_names2{n})
fn =char(field_names{n})
% contourf((((TpD1.(fn2).*(HsD1.(fn).^2))./1000)),colorbar %check visually if it works
P=((((TpD1.(fn2).*(HsD1.(fn).^2))./1000));
Pow(n)=P
% Pow=([])
% Pow(n)=P % This does not work
%
end
then the addition should be
for i=1:11
Average=[]
Average{n} = sum(Pow{n})/11
end
The matrices are 200x200 and I would like to add all together (matricewise), each point represent a different day. That is why all the point in all the matrices have to added and averaged.
How is this possible to be done? I also tried the cell2str command to convert my cell array into structure but no luck, I would prefer if I could save Pow in a structure from the start
thank you

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by