0

Below you will find my code. What I need, is for every loop to save the data that is created in A_wm into TOTAL. I keep getting the error: Subscripted assignment dimension mismatch. I realize this means that the code on the right hand side of the equals sign for TOTAL is not the same size of TOTAL. However, total is preallocated and needs to remain that size. (It has the same # of columns as A_wm but not rows). My idea is that every iteration will save the data in A_wm to a new row in TOTAL. Any suggestions?

mu = .5; 
LAMMDA = 2; 
t = 1:61; 
T0 = 0;
trials = 1:50; 

TOTAL = zeros(50,61); 

for i = trials
    %Clock: Pacemaker ---> Accumulator
    D = t - T0; %effectual switch closure duration
    A_wm = -mu*log(1-rand(1)) * LAMMDA * D;
    TOTAL(i,:) = repmat(A_wm,size(TOTAL,1),1);   
end
Shai
  • 111,146
  • 38
  • 238
  • 371
cwdaniels
  • 71
  • 1
  • 7
  • It is best [not to use `i` as a variable name in Matlab](http://stackoverflow.com/questions/14790740/using-i-and-j-as-variables-in-matlab). – Shai Aug 27 '13 at 07:59

1 Answers1

2

why do you repmat A_wm? try assigning without repmat:

TOTAL(i,:) = A_wm;
Shai
  • 111,146
  • 38
  • 238
  • 371
  • 1
    That worked. I probably assumed that what I was trying to do was may more complicated than it really was. Thanks for your help. – cwdaniels Aug 27 '13 at 19:39