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

4 ビュー (過去 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 Center および File ExchangeModel Verification についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by