Sunday, 15 July 2012

matrix - Solve wrong type argument 'cell' -


I type some value in variable 'O'

  I for = 1: Size (I, 1) for j = 1: Size (1, I) H = I * J; O {h} = i (i, j) * theta (h); End  

I - double, theta - double me sum () all O ' values ​​are required, but when I do this, give me the error: sum: incorrect type argument' cell '. How do I sum () ? Postcode when I want to see O () , give me

  o = {[1,1] = 0.0079764 [1,2] = 0.0035291 [1] , 3] = 0.0027539 [1,4] = 0.0034392 [1,5] = 0.017066 [1,6] = 0.0082958 [1,7] = 1.4764e-04 [1,8] = 0.0024597 [1,9] = 1.1155 E-04 [1,10] = 0.0010342 [1,11] = 0.0039654 [1,12] = 0.0047713 [1,13] = 0.0054305 [1,14] = 3.3794e-04 [1,15] = 0.014323 [1 , 16] = 0.0026826 [1,17] = 0.013864 [1,18] = 0.0097778 [1,19] = 0.0058029 [1,20] = 0.0020726 [1,21] = 0.0016430 etc ...    

Yoga (cell2 matte (your_cell_o))

However, this is a very wrong way to solve your problem. The thing is that You should not have created a cell array in the first place. You should create a numerical array:

  O = zero (size (i), orbit (i)); For I = 1: J = 1 for rows (i): column (i) h = i * j; O (h) = i (i, j) * theta (h);  

For the end is the end but it is actually very bad and slow is the vector language for octave operation. Instead, you should be:

  h = (1: rows (I)) '. * (1: column (I)); #automatic broadcasting = I. * Theta (h);  

which treats your function auspicious correctly and if the given matrix will calculate the value for each element and return some of the same size.

If you get an error about the wrong size, I think you have an older version of Octave which does not autocomplete. If so, update Octave if you really do not Then:

  h = bsxfun (times, (1: rows (I)) ', 1: column (i));  

No comments:

Post a Comment