Matlab Help: Matrix Reduction Algorithm ???
Ältere Kommentare anzeigen
hello every one.. i am a bit new to matlab so have no vocabulary of commands or how thing work as vector matrices or etc etc.. so i would like to develop a prototype or an algorithm for scenario reduction in matlab( each row of a matrix is called as single scenario).
the steps of this algorithms are
1) for any given matrix, find the distance matrix which show euclidean distance between each and every row of original matrix.
2) find the min: value in distance matrix.
3) delete that row with min elemenet value and with min: probabilty of occurance.
4) construct seperate matrix which contain only these deleted rows
5) reconstruct distance matrix with preserved row (without deleted rows).
6) repeat untill the desired numb of rows are preserved.
So I started with a simple 3x3 matrix and i wrote few lines as follow.
--------------------------------------
% suppose any matrix e.g
x=[5 3 1; 2 5 6; 1 3 2];
dist_mat = squeeze(sqrt(sum(bsxfun(@minus,x,reshape(x',1,size(x,2),size(x,1))).^2,2)));
dist_mat(~dist_mat)=inf;
row_min = min(dist_mat);
min_value = min (row_min);
[r c]= find(d==min_value); % shows the position of the minimum element, r= which row and c= which column
so the results i get are
d =
Inf 6.1644 4.1231
6.1644 Inf 4.5826
4.1231 4.5826 Inf
min_value =
4.1231
r =
3
1
c =
1
3
thanks to 'Sean de Wolski' for correcting the dist_mat command.
in my e.g, the min value is in [3,1] and [1,3]. i.e D13=D31, this is correct.
let every row has its own probability, i.e P1= 0.2, P2=0.4, P3=0.4 (total P=1) since the min value = 4.1231 lying in 1st and 3rd row, we can delete either Row1 or Row3, but since the probabilty of Row1 < Row3 so row1 should be selected for deletion. i do not have any thing in mind how to delete this row, rearrange the dist_mat and write a new mat with this deleted row.
I m really sorry for so long post but i wanted to make thing more clear... i hope to get some +ve responses...
Thanks alot in Advance
Akzeptierte Antwort
Weitere Antworten (1)
mehrdad
am 9 Nov. 2013
0 Stimmen
Dear Johann,
In your code ,you define: scennum_fav=250,in your idea how can add Stopping rule for scenario reduction,means,the code ,automatically after done optimization,given the scennum_fav (not given the scennum_fav as input).
Thank you ,
Kategorien
Mehr zu Develop Apps Using App Designer finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!