error using ==> times

조회 수: 3 (최근 30일)
mohd
mohd 2012년 5월 3일
what does it mean that error below. can anyone explain to me. i can not understand the error. thanks
??? Error using ==> times
Integers can only be combined with
integers of the same class, or
scalar doubles.

채택된 답변

James Tursa
James Tursa 2012년 5월 3일
You can do this:
m = int32(1:3);
n = m .* 2; % integer class times scalar double
You can't do this:
m = int32(1:3);
n = m .* [4:6]; % integer class times same size double
So if you need to do the latter, you can do it like this:
m = int32(1:3);
n = m .* int32([4:6]); % integer class times same size same class

추가 답변 (1개)

Junaid
Junaid 2012년 5월 3일
I think whatever vector you are trying to multiplying should have same class (data types). So first you type cast to one class.
like
x = double(x);
  댓글 수: 3
mohd
mohd 2012년 5월 3일
what is that error and how to solve it
Junaid
Junaid 2012년 5월 4일
If your matrix dimension doesn't satisfy the condition of multiplication then you can't multiply them. You have check the Dimenions.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by