Answers

2014-11-26T15:14:41+05:30
 the following code works 
     ⇒scennum_fav is the favored scenario number after reduction
         scennum_fav=250;
     ⇒Initial scenario numbers, my matrix to be reduced is CO2_scen [1000x234]
         scennum_int=size(CO2_scen,1);

      ⇒In the beginning all scenarios are equiprobable
        scenprob=ones(scennum_int,1)*1/scennum_int;
      ⇒scenario reduciton algorithm
       while size(CO2_scen,1)>scennum_fav

      ⇒ Calculate euclidean distances

      dist_mat = queeze(sqrt(sum(bsxfun(@minus,CO2_scen,reshape       (CO2_scen',1,size(CO2_scen,2),size(CO2_scen,1))).^2,2)));
          dist_mat(~dist_mat)=inf;
        row_min = min(dist_mat);
        min_value = min (row_min);

[row column]= find(dist_mat==min_value); % shows the position of the minimum element, r= which row and c= which column

⇒Remove scenario with smallest distance and adding its probability to reference      scenario (the scenario to be removed is independent of its probability)

if scenprob(row(1))>scenprob(row(2))
            CO2_scen(row(2),:)=[];
            scenprob(row(1),:)=scenprob(row(1),:)+scenprob(row(2),:);
            scenprob(row(2),:)=[];
        elseif scenprob(row(1))<scenprob(row(2))
            CO2_scen(row(1),:)=[];
            scenprob(row(2,:))=scenprob(row(2,:))+scenprob(row(1,:));
            scenprob(row(1),:)=[];
        else
            CO2_scen(row(2),:)=[];
            scenprob(row(1,:))=scenprob(row(1,:))+scenprob(row(2,:));
            scenprob(row(2),:)=[];
        end
    end
 
















0