Is there any way to control the concatenation of the blockproc output? - image

This is a follow up to the question: Overlapping sliding window over an image using blockproc or im2col?
So by using the code :
B = blockproc(A, [1 1], #block_fun, 'BorderSize', [2 2], 'TrimBorder', false, 'PadPartialBlocks', true)
I was able to create an overlapping sliding window over my image and calculate the dct2 for each window. But the problem is that blockproc concatenates the output in a way that I cannot use. The output greatly depends on the block size and the size of the output matrix is different because of it every time.
My dct2 function creates a 1 x 200 vector for every block or window. So I assumed that if there are 64 blocks I should get something like 64 x 200 or 200 x 64 output, but I get something like 64 x 1600 or in case of larger blocks I get 15 x 400.
Looking into the blockproc function the problem is caused by
% write 4 corner blocks
b(1:ul_output_size(1),1:ul_output_size(2),:) = ul_output;
if ll_processed
last_row_start = final_rows - size(ll_output,1) + 1;
last_row_width = size(ll_output,2);
b(last_row_start:end,1:last_row_width,:) = ll_output;
end
if ur_processed
last_col_start = final_cols - size(ur_output,2) + 1;
last_col_height = size(ur_output,1);
b(1:last_col_height,last_col_start:end,:) = ur_output;
end
if lr_processed
last_row_start = final_rows - size(ll_output,1) + 1;
last_col_start = final_cols - size(ur_output,2) + 1;
b(last_row_start:end,last_col_start:end,:) = lr_output;
end
Apparently, blockproc further divides the blocks into upper left, upper right, lower left and lower right and concatenates that result. And that is why I am getting all this mixed outputs.
I need the output of each block in its each row, for each window. Each window should just give me a 1x200 output, that I can feed into my classifier.
Can I force the output of blockproc in the way that I want it, just give the output of each block.
If not, I would really appreciate an alternative solution to have an overlapping sliding window over the image.
edit: would it be possible to save the blocks data using block_struct.data for every block into a cell array inside the function block_fun and then use that array to extract my features?
Thank you
edit:
B = blockproc(images_m{1}, [64 64], #(x)reshape(x.data(:),[1 1 numel(x.data)]), 'BorderSize', [10 10], 'TrimBorder', false, 'PadPartialBlocks', true, 'PadMethod', 'replicate');
imgs = {};
for i = 1:size(B,1)
for j = 1:size(B,2)
tempy = squeeze(B(i,j,:));
tempy2 = reshape(tempy, [84 84]);
feats{end+1} = block_dct2(tempy2); %calculates dct2 for the block and returns a 1*200 vector
end
end

Maybe reshape you data in the third dimension?
>> A = magic(3)
A =
8 1 6
3 5 7
4 9 2
>> B = blockproc(A, [1 1], #(x)reshape(x.data(:),[1 1 numel(x.data)]), 'BorderSize', [1 1], 'TrimBorder', false, 'PadPartialBlocks', true);
>> whos B
Name Size Bytes Class Attributes
B 3x3x9 648 double
>> squeeze(B(1,1,:))
ans =
0
0
0
0
8
3
0
1
5
>>

An alternate using MAT2CELL:
function extractFeatures
images_m{1} = rand(128);
B = blockproc(images_m{1}, [64 64], #processBlock,...
'BorderSize', [10 10], 'TrimBorder', false,...
'PadPartialBlocks', true, 'PadMethod', 'replicate');
%B is 2x400 i.e 2x2 blocks of each block being a 1x200 feature vector
m = ones(1,size(B,1));
n = 200*ones(1,size(B,2)/200);
% The MAT2CELL help does a good job, just read it carefully and run the
% examples
feats = mat2cell(B,m,n);
feats = feats(:);
end
function feature = processBlock(bstruct)
% I dont know what block_dct2 does:
%feature = block_dct2(bstruct.data);
% So I'll put in a place holder which returns a 1x200 'feature'
% for each overlapping image block
feature = repmat(mean(bstruct.data(:)), [1 200]);
end

Related

Why does this simple code become slower to execute when I vectorize it?

I have a snippet of code which takes a vector A and creates a new vector C by summing A with both a left and right shifted version of itself (this is based on a centered finite difference formula ). For example, if A = [1 2 3 4 5], then C = [0 6 9 12 0], where the edges are zero because these don't have entries on both sides.
I created two versions, one which loops over element by element in C, and a second which processes the whole array. I measure the "vectorised" version to be around 50 times slower than the loop version... I was expecting the vectorised version to offer a speed improvement, but seems like it is not the case - what am I missing?
A = [1 2 3 4 5];
N = length(A);
C1 = zeros([1, N]);
C2 = zeros([1, N]);
%%% Loop version, element by element %%%
tic
for ntimes = 1:1e6
for m = 2:(N-1)
C1(m) = A(m+1) + A(m-1) + A(m);
end
end
t1 = toc;
disp(['Time taken for loop version = ',num2str(t1)])
%%% Vector version, process entire array at once %%%
tic
for ntimes = 1:1e6
C2(2:(N-1)) = A(3:N) + A(1:(N-2)) + A(2:(N-1));
end
t2 = toc;
disp(['Time taken for vector version = ',num2str(t2)])

Reshape vector to matrix with column-wise zero padding in matlab

for an input matrix
in = [1 1;
1 2;
1 3;
1 4;
2 5;
2 6;
2 7;
3 8;
3 9;
3 10;
3 11];
i want to get the output matrix
out = [1 5 8;
2 6 9;
3 7 10;
4 0 11];
meaning i want to reshape the second input column into an output matrix, where all values corresponding to one value in the first input column are written into one column of the output matrix.
As there can be different numbers of entries for each value in the first input column (here 4 values for "1" and "3", but only 3 for "2"), the normal reshape function is not applicable. I need to pad all columns to the maximum number of rows.
Do you have an idea how to do this matlab-ish?
The second input column can only contain positive numbers, so the padding values can be 0, -x, NaN, ...
The best i could come up with is this (loop-based):
maxNumElem = 0;
for i=in(1,1):in(end,1)
maxNumElem = max(maxNumElem,numel(find(in(:,1)==i)));
end
out = zeros(maxNumElem,in(end,1)-in(1,1));
for i=in(1,1):in(end,1)
tmp = in(in(:,1)==i,2);
out(1:length(tmp),i) = tmp;
end
Either of the following approaches assumes that column 1 of in is sorted, as in the example. If that's not the case, apply this initially to sort in according to that criterion:
in = sortrows(in,1);
Approach 1 (using accumarray)
Compute the required number of rows, using mode;
Use accumarray to gather the values corresponding to each column, filled with zeros at the end. The result is a cell;
Concatenate horizontally the contents of all cells.
Code:
[~, n] = mode(in(:,1)); %//step 1
out = accumarray(in(:,1), in(:,2), [], #(x){[x; zeros(n-numel(x),1)]}); %//step 2
out = [out{:}]; %//step 3
Alternatively, step 1 could be done with histc
n = max(histc(in(:,1), unique(in(:,1)))); %//step 1
or with accumarray:
n = max(accumarray(in(:,1), in(:,2), [], #(x) numel(x))); %//step 1
Approach 2 (using sparse)
Generate a row-index vector using this answer by #Dan, and then build your matrix with sparse:
a = arrayfun(#(x)(1:x), diff(find([1,diff(in(:,1).'),1])), 'uni', 0); %//'
out = full(sparse([a{:}], in(:,1), in(:,2)));
Introduction to proposed solution and Code
Proposed here is a bsxfun based masking approach that uses the binary operators available as builtins for use with bsxfun and as such I would consider this very appropriate for problems like this. Of course, you must also be aware that bsxfun is a memory hungry tool. So, it could pose a threat if you are dealing with maybe billions of elements depending also on the memory available for MATLAB's usage.
Getting into the details of the proposed approach, we get the counts of each ID from column-1 of the input with histc. Then, the magic happens with bsxfun + #le to create a mask of positions in the output array (initialized by zeros) that are to be filled by the column-2 elements from input. That's all you need to tackle the problem with this approach.
Solution Code
counts = histc(in(:,1),1:max(in(:,1)))'; %//' counts of each ID from column1
max_counts = max(counts); %// Maximum counts for each ID
mask = bsxfun(#le,[1:max_counts]',counts); %//'# mask of locations where
%// column2 elements are to be placed
out = zeros(max_counts,numel(counts)); %// Initialize the output array
out(mask) = in(:,2); %// place the column2 elements in the output array
Benchmarking (for performance)
The benchmarking presented here compares the proposed solution in this post against the various methods presented in Luis's solution. This skips the original loopy approach presented in the problem as it appeared to be very slow for the input generated in the benchmarking code.
Benchmarking Code
num_ids = 5000;
counts_each_id = randi([10 100],num_ids,1);
num_runs = 20; %// number of iterations each approach is run for
%// Generate random input array
in = [];
for k = 1:num_ids
in = [in ; [repmat(k,counts_each_id(k),1) rand(counts_each_id(k),1)]];
end
%// Warm up tic/toc.
for k = 1:50000
tic(); elapsed = toc();
end
disp('------------- With HISTC + BSXFUN Masking approach')
tic
for iter = 1:num_runs
counts = histc(in(:,1),1:max(in(:,1)))';
max_counts = max(counts);
out = zeros(max_counts,numel(counts));
out(bsxfun(#le,[1:max_counts]',counts)) = in(:,2);
end
toc
clear counts max_counts out
disp('------------- With MODE + ACCUMARRAY approach')
tic
for iter = 1:num_runs
[~, n] = mode(in(:,1)); %//step 1
out = accumarray(in(:,1), in(:,2), [], #(x){[x; zeros(n-numel(x),1)]}); %//step 2
out = [out{:}];
end
toc
clear n out
disp('------------- With HISTC + ACCUMARRAY approach')
tic
for iter = 1:num_runs
n = max(histc(in(:,1), unique(in(:,1))));
out = accumarray(in(:,1), in(:,2), [], #(x){[x; zeros(n-numel(x),1)]}); %//step 2
out = [out{:}];
end
toc
clear n out
disp('------------- With ARRAYFUN + Sparse approach')
tic
for iter = 1:num_runs
a = arrayfun(#(x)(1:x), diff(find([1,diff(in(:,1).'),1])), 'uni', 0); %//'
out = full(sparse([a{:}], in(:,1), in(:,2)));
end
toc
clear a out
Results
------------- With HISTC + BSXFUN Masking approach
Elapsed time is 0.598359 seconds.
------------- With MODE + ACCUMARRAY approach
Elapsed time is 2.452778 seconds.
------------- With HISTC + ACCUMARRAY approach
Elapsed time is 2.579482 seconds.
------------- With ARRAYFUN + Sparse approach
Elapsed time is 1.455362 seconds.
slightly better, but still uses a loop :(
out=zeros(4,3);%set to zero matrix
for i = 1:max(in(:,1)); %find max in column 1, and loop for that number
ind = find(in(:,1)==i); %
out(1: size(in(ind,2),1),i)= in(ind,2);
end
don't know if you can avoid the loop...

Indexing a matrix with predetermined rule

I have P <151x1 double> and D <6x1 double>. An example of D would be [24;7;9;11;10;12]. I have to index P based on D such that in P I want to keep 6 blocks of 12 elements but each block is separated from the next block by n number of elements. n is given by D. The first 12 elements of P is the first block. Thus, the first block would be P(1:12), the second block would be P(37:48,1) because we want to skip 24 elements after the first block (24 is D(1,1), Third block to keep would be P(56,1) because we want to skip 7 elements after the second block (7 is D(2,1)), etc. After indexing I should end up with 72 elements.
Could anyone help me find a solution to indexing this efficiently?
Thanks!
One approach -
%// Parameters
block_size = 12;
num_blocks = 6;
step_add = [0 ; cumsum(D(1:num_blocks-1))];
start_ind = [0:block_size:block_size*(num_blocks-1)]'+1 + step_add; %//'
all_valid_ind = bsxfun(#plus,start_ind,0:block_size-1)'; %//'
out = P(all_valid_ind(:)); %// desired output
Please note that you won't be using the last element of D into the calculations, because each element of D defines the "gap" between consecutive blocks of elements that you are picking up from P.So you need only 5 elements to define 5 gaps between 6 blocks of elements .
Benchmarking
Loop approach from this solution:
function blocks = loop1(P,D)
blocks = zeros(12, numel(D)); % //Pre-allocate blocks matrix
%// We start accessing values at 1
startIndex = 1;
%// For each index in D
for idx = 1 : numel(D)
%// Grab the 12 elements
blocks(:,idx) = P(startIndex : startIndex + 11);
%// Skip over 12 elements PLUS the number specified at D
startIndex = startIndex + 12 + D(idx);
end
return;
No-loop approach (as discussed earlier in this solution):
function out = no_loop1(P,D)
%// Parameters
block_size = 12;
num_blocks = numel(D);
step_add = [0 ; cumsum(D(1:num_blocks-1))];
start_ind = [0:block_size:block_size*(num_blocks-1)]'+1 + step_add; %//'
all_valid_ind = bsxfun(#plus,start_ind,0:block_size-1)'; %//'
out = P(all_valid_ind(:)); %// desired output
return;
Actual benchmarking and plotting results:
P = rand(200000,1);
N_arr = [100 200 500 1000 2000 5000]; %// No. of D elements
timeall = zeros(2,numel(N_arr));
for k1 = 1:numel(N_arr)
N = N_arr(k1);
D = randi(10,N,1)+10;
f = #() loop1(P,D);
timeall(1,k1) = timeit(f);
clear f
f = #() no_loop1(P,D);
timeall(2,k1) = timeit(f);
clear f
end
figure,
hold on
plot(N_arr,timeall(1,:),'-ro')
plot(N_arr,timeall(2,:),'-kx')
legend('Loop Method','No-loop Method')
xlabel('Datasize (No. of D elements) ->')
ylabel('Time(sec) ->')
Results
Conclusions
No-loop approach as used in this solution looks the more efficient one across a varying range of datasizes.
Because this is using a recurrence relation, the only option I can see is using for loops. We must use output values from the previous iteration as input into the next iteration. I personally can't see any technique in my arsenal that can do this vectorized.
If there is anyone else (Divakar, Luis Mendo, natan, Ben, Daniel, Amro, etc.) that can propose a more optimum solution, please feel free and answer. Without further ado:
D = [24;7;9;11;10;12]; %// Define number of elements to skip over
blocks = zeros(12, numel(D)); % //Pre-allocate blocks matrix
%// We start accessing values at 1
startIndex = 1;
%// For each index in D
for idx = 1 : numel(D)
%// Grab the 12 elements
blocks(:,idx) = P(startIndex : startIndex + 11);
%// Skip over 12 elements PLUS the number specified at D
startIndex = startIndex + 12 + D(idx);
end
This should give you a 12 x 6 matrix, where each column corresponds to the set of elements you extracted from P. As a small test, we can display the start and ending indices that we need to access P for extracting elements. These are generated by replacing blocks(:,idx) = ..., with disp([startIndex startIndex + 11]); in the loop. The indices generated are:
1 12
37 48
56 67
77 88
100 111
122 133
This can be vectorized, no problem.
P = 1:200; % a generic P
D = [24;7;9;11;10;12];
D = [0 D(1:end-1)];
basis = repmat(0:11, [6 1]);
startingIndices = cumsum(D + 12) + 1;
usefulIndices = bsxfun(#plus, basis, startingIndices);
P(usefulIndices)
Without some more context, it's hard to suggest a method that indexes this "efficiently" -- if you're only doing this operation a few times, clarity of code is the most important. But I think this will give you a good starting point.

bsxfun implementation in matrix multiplication

As always trying to learn more from you, I was hoping I could receive some help with the following code.
I need to accomplish the following:
1) I have a vector:
x = [1 2 3 4 5 6 7 8 9 10 11 12]
2) and a matrix:
A =[11 14 1
5 8 18
10 8 19
13 20 16]
I need to be able to multiply each value from x with every value of A, this means:
new_matrix = [1* A
2* A
3* A
...
12* A]
This will give me this new_matrix of size (12*m x n) assuming A (mxn). And in this case (12*4x3)
How can I do this using bsxfun from matlab? and, would this method be faster than a for-loop?
Regarding my for-loop, I need some help here as well... I am not able to storage each "new_matrix" as the loop runs :(
for i=x
new_matrix = A.*x(i)
end
Thanks in advance!!
EDIT: After the solutions where given
First solution
clear all
clc
x=1:0.1:50;
A = rand(1000,1000);
tic
val = bsxfun(#times,A,permute(x,[3 1 2]));
out = reshape(permute(val,[1 3 2]),size(val,1)*size(val,3),[]);
toc
Output:
Elapsed time is 7.597939 seconds.
Second solution
clear all
clc
x=1:0.1:50;
A = rand(1000,1000);
tic
Ps = kron(x.',A);
toc
Output:
Elapsed time is 48.445417 seconds.
Send x to the third dimension, so that singleton expansion would come into effect when bsxfun is used for multiplication with A, extending the product result to the third dimension. Then, perform the bsxfun multiplication -
val = bsxfun(#times,A,permute(x,[3 1 2]))
Now, val is a 3D matrix and the desired output is expected to be a 2D matrix concatenated along the columns through the third dimension. This is achieved below -
out = reshape(permute(val,[1 3 2]),size(val,1)*size(val,3),[])
Hope that made sense! Spread the bsxfun word around! woo!! :)
The kron function does exactly that:
kron(x.',A)
Here is my benchmark of the methods mentioned so far, along with a few additions of my own:
function [t,v] = testMatMult()
% data
%{
x = [1 2 3 4 5 6 7 8 9 10 11 12];
A = [11 14 1; 5 8 18; 10 8 19; 13 20 16];
%}
x = 1:50;
A = randi(100, [1000,1000]);
% functions to test
fcns = {
#() func1_repmat(A,x)
#() func2_bsxfun_3rd_dim(A,x)
#() func2_forloop_3rd_dim(A,x)
#() func3_kron(A,x)
#() func4_forloop_matrix(A,x)
#() func5_forloop_cell(A,x)
#() func6_arrayfun(A,x)
};
% timeit
t = cellfun(#timeit, fcns, 'UniformOutput',true);
% check results
v = cellfun(#feval, fcns, 'UniformOutput',false);
isequal(v{:})
%for i=2:numel(v), assert(norm(v{1}-v{2}) < 1e-9), end
end
% Amro
function B = func1_repmat(A,x)
B = repmat(x, size(A,1), 1);
B = bsxfun(#times, B(:), repmat(A,numel(x),1));
end
% Divakar
function B = func2_bsxfun_3rd_dim(A,x)
B = bsxfun(#times, A, permute(x, [3 1 2]));
B = reshape(permute(B, [1 3 2]), [], size(A,2));
end
% Vissenbot
function B = func2_forloop_3rd_dim(A,x)
B = zeros([size(A) numel(x)], 'like',A);
for i=1:numel(x)
B(:,:,i) = x(i) .* A;
end
B = reshape(permute(B, [1 3 2]), [], size(A,2));
end
% Luis Mendo
function B = func3_kron(A,x)
B = kron(x(:), A);
end
% SergioHaram & TheMinion
function B = func4_forloop_matrix(A,x)
[m,n] = size(A);
p = numel(x);
B = zeros(m*p,n, 'like',A);
for i=1:numel(x)
B((i-1)*m+1:i*m,:) = x(i) .* A;
end
end
% Amro
function B = func5_forloop_cell(A,x)
B = cell(numel(x),1);
for i=1:numel(x)
B{i} = x(i) .* A;
end
B = cell2mat(B);
%B = vertcat(B{:});
end
% Amro
function B = func6_arrayfun(A,x)
B = cell2mat(arrayfun(#(xx) xx.*A, x(:), 'UniformOutput',false));
end
The results on my machine:
>> t
t =
0.1650 %# repmat (Amro)
0.2915 %# bsxfun in the 3rd dimension (Divakar)
0.4200 %# for-loop in the 3rd dim (Vissenbot)
0.1284 %# kron (Luis Mendo)
0.2997 %# for-loop with indexing (SergioHaram & TheMinion)
0.5160 %# for-loop with cell array (Amro)
0.4854 %# arrayfun (Amro)
(Those timings can slightly change between different runs, but this should give us an idea how the methods compare)
Note that some of these methods are going to cause out-of-memory errors for larger inputs (for example my solution based on repmat can easily run out of memory). Others will get significantly slower for larger sizes but won't error due to exhausted memory (the kron solution for instance).
I think that the bsxfun method func2_bsxfun_3rd_dim or the straightforward for-loop func4_forloop_matrix (thanks to MATLAB JIT) are the best solutions in this case.
Of course you can change the above benchmark parameters (size of x and A) and draw your own conclusions :)
Just to add an alternative, you maybe can use cellfun to achieve what you want. Here's an example (slightly modified from yours):
x = randi(2, 5, 3)-1;
a = randi(3,3);
%// bsxfun 3D (As implemented in the accepted solution)
val = bsxfun(#and, a, permute(x', [3 1 2])); %//'
out = reshape(permute(val,[1 3 2]),size(val,1)*size(val,3),[]);
%// cellfun (My solution)
val2 = cellfun(#(z) bsxfun(#and, a, z), num2cell(x, 2), 'UniformOutput', false);
out2 = cell2mat(val2); % or use cat(3, val2{:}) to get a 3D matrix equivalent to val and then permute/reshape like for out
%// compare
disp(nnz(out ~= out2));
Both give the same exact result.
For more infos and tricks using cellfun, see: http://matlabgeeks.com/tips-tutorials/computation-using-cellfun/
And also this: https://stackoverflow.com/a/1746422/1121352
If your vector x is of lenght = 12 and your matrix of size 3x4, I don't think that using one or the other would change much in term of time. If you are working with higher size matrix and vector, now that might become an issue.
So first of all, we want to multiply a vector with a matrix. In the for-loop method, that would give something like that :
s = size(A);
new_matrix(s(1),s(2),numel(x)) = zeros; %This is for pre-allocating. If you have a big vector or matrix, this will help a lot time efficiently.
for i = 1:numel(x)
new_matrix(:,:,i)= A.*x(i)
end
This will give you 3D matrix, with each 3rd dimension being a result of your multiplication. If this is not what you are looking for, I'll be adding another solution which might be more time efficient with bigger matrixes and vectors.

Partition an image into 8 rows via Matlab, not all partitions shown

I wish to ask if anybody out there knows how to partition an image into 8 different rows and 1 column? I have tried using mat2cell() and using the demo on their wiki as a reference, I tried partitioning the image into 8 rows, however not all image partition rows are displayed.
If you see the image below, 2, 4, 6, 8 is not displayed. I am also not sure why is it of 16 blocks.
Can somebody help me check my code? I am not really used to the MatLab syntax and language. I trying my best to understand now.
My code for splitting the blocks are as follows:
blockSizeR = 50; % Rows in block.
blockSizeC = 512; % Columns in block.
wholeBlockRows = floor(rows / blockSizeR);
blockVectorR = [blockSizeR * ones(1, wholeBlockRows), rem(rows, blockSizeR)];
wholeBlockCols = floor(columns / blockSizeC);
blockVectorC = [blockSizeC * ones(1, wholeBlockCols), rem(columns, blockSizeC)];
if numberOfColorBands > 1
% It's a color image.
ca = mat2cell(rgbImage, blockVectorR, blockVectorC, numberOfColorBands);
else
ca = mat2cell(rgbImage, blockVectorR, blockVectorC);
end
% Now display all the blocks.
plotIndex = 1;
numPlotsR = size(ca, 1);
numPlotsC = size(ca, 2);
for r = 1 : numPlotsR
for c = 1 : numPlotsC
fprintf('plotindex = %d, c=%d, r=%d\n', plotIndex, c, r);
% Specify the location for display of the image.
subplot(numPlotsR, 1, plotIndex);
% Extract the numerical array out of the cell
% just for tutorial purposes.
rgbBlock = ca{r,c};
imshow(rgbBlock); % Could call imshow(ca{r,c}) if you wanted to.
[rowsB columnsB numberOfColorBandsB] = size(rgbBlock);
% Make the caption the block number.
caption = sprintf('Block #%d of %d\n%d rows by %d columns', ...
plotIndex, numPlotsR*numPlotsC, rowsB, columnsB);
title(caption);
drawnow;
% Increment the subplot to the next location.
plotIndex = plotIndex + 1;
end
end
I am new to MatLab, so is there is a simpler method to do this that I missed out, please do suggest or better still, if there are references that I can refer to. Many thanks (:
If you know the dimensions of your matrix, you can do the math to figure out how to divide the number of rows into 4 equal parts:
e.g. If: size(rockinsMatrix) == [10 20] (a 10row x 20column) matrix,
then you could split it into a set of 4 sub-matrices, two with 3 rows, and 2 with 2 columns.
If you want the matrices in a cell array then you can do that at that time.
I managed to solve already, the error lies in the for loop. I changed the for r = 1 : numPlotsR into r = 1 : (number of rows I want) for c = 1 : numPlotsC into c= 1: 1(as I only want one column), and used subplot(8,1,k) or (8,2,k) where k is the plot index. Just answering this in case anybody encounter such problem in future and want to use my code as a reference. Cheers!

Resources