Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Error Integers can only be combined with integers of the same class, or scalar doubles when processing my sample?

Asked by I Made on 11 Mar 2013

I have a3, it's data < 64x490 int16 > , and i wanted to do *row1*row1*1 then row2*row2*2 to row49*row49*49 and have the sum of it. And apply it to all other columns too. i have tried using this code :


but i get this error message : ??? Error using ==> times Integers can only be combined with integers of the same class, or scalar doubles.

this code work only if we remove the .*m and become like this:


but the formula from row1*row1*1 become row1*row1 only, can anyone correct my mistake ?


I Made


No products are associated with this question.

2 Answers

Answer by Image Analyst on 11 Mar 2013


m = int16(1:g);

Be aware that if the numbers get larger than 32767, they will clip.


Image Analyst
Answer by Wayne King on 11 Mar 2013

The error you get is because

m = 1:g;

gives you a double precision vector, while a3 is int16. You can remove that error by casting m to int16

 m = int16(1:g);

or a3 to double precision

a3 = double(a3);

but then you're going to get dimension error. Did you mean to have a for loop?

1 Comment

I Made on 11 Mar 2013

yeah you right, actually i need to be n=1,2,3,4,5... as i wanted to have a sum of(sampel(n)*sample(n)*n), where n is the number of row. to be more clear let me explain a bit :

so i have e.g

4 5 3

5 4 1

2 1 2

i wanted to got

78 60 23

and the process is like :

Column 1->(4*4*1)+(5*5*2)+(2*2*3) then Column 2->(5*5*1)+(4*4*2)+(1*1*3) then Column 3->(3*3*1+1*1*2+2*2*3)

How can i achieve this?

Wayne King

Contact us