Please help, I'm trying to make a function but I keep getting major errors and I dont know why.

조회 수: 3 (최근 30일)
function [y,x]=position(N,IS)
for i=1:N
if IS(i)==1 % checks if ligand is active and give new position
dx=randi([-360,360],1);
dy=randi([-50,50],1);
x(i)=x(i)+dx;
y(i)=y(i)+dy;
end
end
The errors are this
Not enough input arguments.
Error in position (line 4)
if IS(i)==1 % checks if ligand is active and give new position

답변 (1개)

Image Analyst
Image Analyst 2023년 5월 4일
Did you assign the input arguments before you called it, liks
N = 5;
IS = ones(N, 1);
[y,x]=position(N,IS)
Probably not. You probably just clicked the green run triangle without sending in any input arguments. You can't do that if input arguments are required. You must assign them and pass them in. You can do this in the command window or a script.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by