Here is my code thus far:
function [ outData ] = splitTrial( rawData, numTrial ) %SPLITTRIAL Summary of this function goes here % Detailed explanation goes here
numRows = round(length(rawData)/(numTrial)); outData = zeros(numRows, numTrial); for i = 1:numTrial
outData(:,i) = rawData(1,:);
rawData represents loaded EMG data with 3605 elements ( 3605 X 1 matrix). The number of columns for outData is simply the number of trials. I can't, however, come up with a general algorithm to replace column wise the elements from the raw data into outdate with the proper matrix dimensions specified in the above reallocated matrix. Any help would be greatly appreciated!
No products are associated with this question.
Also format the code you do have so it's legible...if it doesn't look right in the preview window the posting isn't ready for prime time.
It would seem that if the number of trials is evenly divisible into the length of the vector (and if it's not, you need another variable vector to indicate the length of each trial) that the output rearranged would simply be
This will give nPerTrial columns.
As noted above, if
then you've got a problem that's insoluble w/o additional information.
Is this what you want?
A = [ 1 3 5; 2 4 6]; B = [0 0 0; 0 0 0];
B(1:2,1) = A(1:2,1)
1 0 0 2 0 0
...How do I index an entire column of a matrix but only part of a row of that same matrix?
Star's answer generalized...
is the submatrix from row r1 thru r2 for the column col. Write an address expression of any sort for the assignment that is of commensurate size in each dimension for the target.
The above can be expanded to include a specific delta rather than the default unitary step as
and the "Getting Started" documentation for details.
I wonder again, though, regarding the original problem that raised the question if there isn't a more expeditious solution if you'd define the actual data structure more fully. Is there an issue in an erroneous assumption in my previous answer?