MATLAB: Matlab code to psudocode

algorithmMATLAB

Can anybody please tranlsate this Matlab code to Psudocode.
DR=DATARESOURCE
T= TIME
DS= DATASET
DR=[ 10 20 30 40 50; 29 32 43 57 60; 41 54 63 77 80 ; 21 33 45 99 76; 17 82 44 68 91];
for i=1:5
T{i} = (DR(:,i));
DS{i}=( DR(i,:));
sumDS{i}=sum(DS{i});
end

Best Answer

I will do you one better: I will write comments with each line, which the writer of this code should have done. Then you can easily convert it to pseudocode.
DR=[ 10 20 30 40 50; 29 32 43 57 60; 41 54 63 77 80 ; 21 33 45 99 76; 17 82 44 68 91];
for i=1:5
T{i} = DR(:,i);%store a col of DR in the time array
DS{i}= DR(i,:);%store a row of DR in the DS array
sumDS{i}=sum(DS{i});%compute the sum of the row
end
This code can be optimized a lot, but without knowing the context of this code, it is tricky to give solid advice about which parts should definitely be changed. I supect something like this is a step in the right direction:
DR=[ 10 20 30 40 50; 29 32 43 57 60; 41 54 63 77 80 ; 21 33 45 99 76; 17 82 44 68 91];
T=mat2cell(DR,size(DR,1),ones(1,size(DR,2))); %split DR by column
DS=mat2cell(DR,ones(1,size(DR,1)),size(DR,2));%split DR by row
sumDS=num2cell(sum(DR,2));%compute row-sum
%or alternatively:
%sumDS=cellfun(@sum,DS,'UniformOutput',false);