11-09-2010 12:15 AM
Hi,
I had been working on some matrix manipulation in Matlab and would like to know if Labview could handle 1D array type of index instead of a constant. Here is the example of the Matlab code. I'm trying to represent the exact piece of code using For loops and Set Submatrix function but couldn't get the exact answer given by Matlab. Could anybody help me on this problem?
Regards,
Syariful
PSI = zeros(103,30);
y1 = rand(11,10);
y2 = [1 2 3 4 5 6 7 8 9 10;
11 12 13 14 15 16 17 18 19 20;
21 22 23 24 25 26 27 28 29 30;
31 32 33 34 35 36 37 38 39 40;
41 42 43 44 45 46 47 48 49 50;
51 52 53 54 55 56 57 58 59 60;
61 62 63 64 65 66 67 68 69 70];
hidden = 10;
inputs = 6;
index = [34 41 48 55 62 69 76 83 90 97];
index2 = [0 3 6 9 12 15 18 21 24 27];
for i=1:3,
index1 = (i-1)*(hidden+1)+1;
PSI(index1:index1+hidden,index2+i) = y1;
for j=1:10;
PSI(index(j):index(j)+inputs,index2+i) = y2;
end
end
11-09-2010 01:15 PM
I'm not sure I understand what you mean by an "array type of index instead of a constant". Indexes are just values. As far as your Matlab code is concerned, it appears that you're basically just performing array substitutions, and there's the Replace Array Subset function in LabVIEW. What exactly are you having problems with?
11-10-2010 08:30 PM
I had tried to use Replace Array Subset function and it seem to be bit difficult to manipulate array indexes over some length, which why I use the Set Submatrix instead. Anyway I attached the vi that I had used to test the code. What I couldn't understand was why the answer produce in Labview didn't match the answer produce by the matlab code.