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

1 visualización (últimos 30 días)
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

Respuestas (1)

Image Analyst
Image Analyst el 4 de Mayo de 2023
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.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by