From: Neil Stewart on 5 Aug 2010 06:01 Hi everyone, I'm currently having a problem with some code that creates a matrix through vectorisation rather than a loop (to increase speed). I'm having a little trouble figuring out how to do this as it is not the same process as I have used to create other matrices with vectorisation. I'm sure there's a simple solution but it's been evading me so far. Here's my problem. I wish to create a matrix 'Qwert' which should (after the vectorisation process) be of the dimensions [length(row12) x length(row21)] - where row12 is the vector 1:m and row21 is the vector 1:n; m<<n. If I were to write it as index locations, Qwert would look like this: Qwert = MRAA subs[row12 , WSRR subs(row21)] [b]where subs means subscript (denoting index location)[/b] (i.e. not in matlab form) MRAA is another matrix of dimensions [length(row12) x 181] WSRR is an array from 1:n, containing values (1<=values<=181, all of which are integers) So, for example, the first cell in Qwert - Qwert subs(1 , 1) = MRAA subs[1 , WSRR subs(1)] and Qwert subs(18 , 278) = MRAA subs[18 , WSRR subs(278)] Basically it plops a column from MRAA indicated by the integer found in WSRR into a new column in Qwert. I hope you get the idea! Any help would be appreciated. Just ask if you don't understand what I'm trying to say. Communication of ideas isn't my strongest suit! Cheers, Neil
From: Neil Stewart on 5 Aug 2010 07:02 I feel I should write it more simply (long winded much?). I want Qwert to be made up from the columns of MRAA. Qwwert should be made up like this: First Column -> find integer value in first cell of WSRR, that integer corresponds to a column in MRAA, that column goes in first column of Qwert. All other Columns -> repeat Hope this is more black and white. Cheers, Neil
From: Andy on 5 Aug 2010 08:38 "Neil Stewart" <neil.stewart(a)lr.org> wrote in message <i3e5nd$qga$1(a)fred.mathworks.com>... > I feel I should write it more simply (long winded much?). > > I want Qwert to be made up from the columns of MRAA. > > Qwwert should be made up like this: > > First Column -> find integer value in first cell of WSRR, that integer corresponds to a column in MRAA, that column goes in first column of Qwert. > All other Columns -> repeat > > Hope this is more black and white. > > Cheers, > Neil Nope, still not black and white. Please give a small sample of input and the desired output.
From: Neil Stewart on 5 Aug 2010 09:03 "Andy " <myfakeemailaddress(a)gmail.com> wrote in message > > Nope, still not black and white. Please give a small sample of input and the desired output. Ok, I'll give it a wee go. INPUT: MRAAsmall = [1 2 3 4 5 6 7;2 4 6 8 10 12 14;3 6 9 12 15 18 21] WSRRsmall = [1 5 6 6 3 2 7 1 1 4 3 2] OUTPUT: Qwertsmall = transpose([1 2 3; 5 10 15; 6 12 18; 6 12 18; 3 6 9; 2 4 6; 7 14 21; 1 2 3; 1 2 3; 4 8 12; 3 6 9; 2 4 6]) Neil
From: Andy on 5 Aug 2010 10:36 "Neil Stewart" <neil.stewart(a)lr.org> wrote in message <i3ecq8$sei$1(a)fred.mathworks.com>... > "Andy " <myfakeemailaddress(a)gmail.com> wrote in message > > > > > Nope, still not black and white. Please give a small sample of input and the desired output. > > Ok, I'll give it a wee go. > > INPUT: > MRAAsmall = [1 2 3 4 5 6 7;2 4 6 8 10 12 14;3 6 9 12 15 18 21] > WSRRsmall = [1 5 6 6 3 2 7 1 1 4 3 2] > > OUTPUT: > Qwertsmall = transpose([1 2 3; 5 10 15; 6 12 18; 6 12 18; 3 6 9; 2 4 6; 7 14 21; 1 2 3; 1 2 3; 4 8 12; 3 6 9; 2 4 6]) > > Neil MRAAsmall = [1 2 3 4 5 6 7;2 4 6 8 10 12 14;3 6 9 12 15 18 21]; WSRRsmall = [1 5 6 6 3 2 7 1 1 4 3 2]; [tf,loc]=ismember(WSRRsmall,MRAAsmall(1,:)); Qwertsmall = MRAAsmall(:,loc);
|
Next
|
Last
Pages: 1 2 Prev: how to optimize mixed parameters? Next: Eliminating negative zeros in a matrix |