Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

I"m having problems making this a callable function, How can I fix it,

조회 수: 2 (최근 30일)
BAILEY MCMASTER
BAILEY MCMASTER 2023년 5월 3일
마감: Stephen23 2023년 5월 4일
function [dx,dy,y,x,x_prv,y_prv]=position(N,L,x,y)
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
x_prv=x;
y_prv=y;
x=mod(x,L);
y=mod(y,L);
%% my orignal code, my intialization function makes my IS=ones(N,1)
%% Bailey McMaster Comp methods Final project
N=10; % number of integrins
L=100; % size of the domain 100nm
dt=1; % time step
F=randi([1, 10],1); % force on the bond with a random number of 1 to 10
P_a=randi([0,1],1); % binding rate of a random number from 0 to 1
P_ub=1/(1.5*F); % unbinding rate based upon our previous values
Tmax=500; % max time
% Intialize our integrins
[x,y,IS]=intialization(N);
% our figure
figure
axis([0 L 0 L]);
set(gca,'nextplot','replacechildren');
x_prv=x;
y_prv=y;
% position update
for t = 0:dt:Tmax
% colors for our integrin states
colors = repmat([1 0 0], N,1); % red for inactive state
colors(IS == 2,:,:) = repmat([0 1 0],sum(IS == 2),1);
% plotting our integrins
scatter(x,y,50,colors,'filled');
hold on
quiver(x_prv,y_prv,x-x_prv,y-y_prv,'k','AutoScale','off')
hold off;
title(sprintf('Time=%.2f',t));
drawnow;
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
x_prv=x;
y_prv=y;
x=mod(x,L);
y=mod(y,L);
for i=1:N
w=randi([0,1],1);
if w < P_a && IS(i)==1
IS(i)=2;
end
end
for i=1:N
w1=randi([0,1],1);
if IS(i)==2 && w1<P_ub
IS(i)=1;
end
end
Di=sqrt((mean(x.^2))/N); % Displacement of each particle calculated each loop
end
  댓글 수: 1
Steven Lord
Steven Lord 2023년 5월 3일
What happens when you try to call it like any other MATLAB function? How do you try to call it?
  • Do you receive warning and/or error messages? If so the full and exact text of those messages (all the text displayed in orange and/or red in the Command Window) may be useful in determining what's going on and how to avoid the warning and/or error.
  • Does it do something different than what you expected? If so, what did it do and what did you expect it to do?
  • Did MATLAB crash? If so please send the crash log file (with a description of what you were running or doing in MATLAB when the crash occured) to Technical Support so we can investigate.

답변 (0개)

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by