I have a little problem with my matrix. Perhaps you interested with this..
I have matrix like below :
xdata = [ 1 2 0.0192 1 3 0.0452 2 4 0.0570 3 4 0.0132 2 5 0.0472 2 6 0.0581 4 6 0.0119 5 7 0.0460 6 7 0.0267 6 8 0.0120 6 9 0.0 6 10 0.0 9 11 0.0 ];
I want to call a variable in that matrix one by one following my loop order. For example :
Q = 0;K = 0;n = length(xdata);i = xdata(:,1);j = xdata(:,2);for bb = 1:n, for cc = 1:n, c1 = xdata(:,1); c2 = xdata(:,2); if c1 == bb, if c2 == cc, K = linedata(:,3); end end Q = Q + (K*100); endend
so when bb = 1 and cc = 2, K will call xdata(:,3) in line 1 = 0.0192
when bb = 1 and cc = 3, K will call xdata(:,3) in line 2 = 0.0452
when bb = 6 and cc = 7, K will call xdata(:,3) in line 9 = 0.0267, and so on…
My code above are wrong and I feel really dizzy when coding it, maybe you can help me with this..
anyone has the solution..?
thanks…
Best Answer