I am perplexed by the fact that niether loop indeces or the number 3 are considered integers.
The script (called WhyNotIntegers)
for i = 1:3
idivide(i,3,'round')
end
produces these errors when run:
Error using idivide>idivide_check (line 66)
At least one argument must belong to an integer class.
Error in idivide (line 42)
idivide_check(a,b);
Error in WhyNotIntegers (line 2)
idivide(i,3,'round')
Error in run (line 96)
evalin('caller', [script ';']);

 채택된 답변

Image Analyst
Image Analyst 2019년 2월 22일

0 개 추천

They're doubles that just happen to have integer values. Convert them to integers since that's what idivide wants. Try this:
for k = 1:3
idivide(int32(k), int32(3),'round')
end

댓글 수: 1

Thanks to both of you for the fast answers.
Stephan got there first, but this told me exactly what I needed to do.
Alex

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

추가 답변 (1개)

Stephan
Stephan 2019년 2월 22일
편집: Stephan 2019년 2월 22일

0 개 추천

Hi,
by default numbers in Matlab are double. cast them to integer:
int32(i)
Read here:
Best regards
Stephan

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

릴리스

R2016b

태그

Community Treasure Hunt

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

Start Hunting!

Translated by