Info

此问题已关闭。 请重新打开它进行编辑或回答。

how can i use for loop for the given situation

1 次查看(过去 30 天)
X=randi([1,5],3,1);
Y=randi([1,5],3,1);
for i=1:3;
Xnew(i)=[X(i,1)+.6];Xn=Xnew';
Ynew(i)=[Y(i,1)+.4];Yn=Ynew';
end
plot(Xn,Yn,'kd');
grid on;hold on;
D2X=randi([1,5],3,1);
D2Y=randi([1,5],3,1);
plot(D2X,D2Y,'ro');hold off;
axis([1,50,1,50]);
my problem is like on the first day source is generating three particles then these three particles move with the groundwater velocity, on the second day three particles again are generated by the source, on the third day again three particles by source and former particles will be moving with the groundwater velocity, source generates particles in a definite range only lets say (0-5). this will continue till 365 days.
  1 个评论
Adam
Adam 2015-6-26
Please format your code to be more readable.
Also your description seems to bear no relation to your code. You talk about concepts of days, sources, particles, velocities, etc yet your code just has X, Y, D2X, etc variables. You can't assume we instantly know everything about your problem domain.
Try to keep the question terminology and the code terminology matched up (i.e. use meaningful variable names). It is far better for yourself and anyone else who needs to understand your code as well as for people expected to answer your question!

回答(0 个)

此问题已关闭。

标签

Community Treasure Hunt

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

Start Hunting!

Translated by