필터 지우기
필터 지우기

Error "Size input must be scalar"

조회 수: 2 (최근 30일)
Chaudhary P Patel
Chaudhary P Patel 2022년 9월 27일
편집: Image Analyst 2022년 9월 27일
Sir, Here delu=randi(30,1), in which i want to add zeros(3,1) but when i am running this in my complete code it is showing "Size input must be scalar".
Please help me out with it.
delu=randi(30,1);
delU=([zeros(3,1);delu]);
  댓글 수: 1
Rik
Rik 2022년 9월 27일
편집: Image Analyst 2022년 9월 27일
Your code runs without error, as you can see.
delu=randi(30,1);
delU=([zeros(3,1);delu])
delU = 4×1
0 0 0 3

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

답변 (1개)

Image Analyst
Image Analyst 2022년 9월 27일
MATLAB is case sensitive so delu is different than delU. Try this:
delu=randi(30,1) % Generate a single integer in the range 1-30
delu = 9
delu=([zeros(3,1);delu]) % Prepend 3 zeros above that number so it's now 4 rows tall.
delu = 4×1
0 0 0 9
whos delu
Name Size Bytes Class Attributes delu 4x1 32 double
  댓글 수: 2
Chaudhary P Patel
Chaudhary P Patel 2022년 9월 27일
delU=([zeros(3,1);delu]) % This is U not u
Image Analyst
Image Analyst 2022년 9월 27일
편집: Image Analyst 2022년 9월 27일
OK but it still works, you just have two variables with extremely similar spelling, which of course will be very confusing:
delu=randi(30,1) % Generate a single integer in the range 1-30
delu = 2
delU=([zeros(3,1);delu]) % Prepend 3 zeros above that number so it's now 4 rows tall.
delU = 4×1
0 0 0 2
whos delU
Name Size Bytes Class Attributes delU 4x1 32 double
So why isn't it working for you? You are not even calling the size() function like the error says. You need to give us ALL your code.

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

카테고리

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