Info
This question is closed. Reopen it to edit or answer.
Here is my code, i want to find the end value of variable "time" for each loop and want to store all the end values in a vector, how can i do this job? Thank you
1 view (last 30 days)
Show older comments
clear all;
tw=.5*10^(-12);
tw1=.5*10^(-12)/(2.418884326505*10^(-17));
Fm=40*10^5/(5.14220652*10^11);
Am=-Fm*tw1*exp(1/2)/sqrt(2);
k0=sqrt(2*.055/(27.211385));
dt=(10^(-12))./1000;
N=5;
starttime(1)=-.7*10^(-12);
A1(1)=-Fm*tw1*exp(-(starttime(1)./tw).^2)*exp(1/2)/sqrt(2);
figure();
hold on;
for j=linspace(1,N,N)
dt1=(.7*10^(-12)-(.5*10^(-12)))/N;
t1(j+1)=starttime(j)+dt1;
A1(j)=-Fm*tw1*exp(-(starttime(j)./tw).^2)*exp(1/2)/sqrt(2);
i=1;
t(1)=starttime(j);
z(1)=0;
while z(i) >= 0
time(i+1)=time(i)+dt;
A(i)=-Fm*tw1*exp(-(time(i)./tw).^2)*exp(1/2)/sqrt(2);
z(i+1) = z(i) +(k0-A1(j))*dt+A(i)*dt;
i = i+1;
end
plot(time/10^(-12),z/(5.2917721092*10^(-14)),'.')
% hold on
plot([-.7,0],[0,0],'r--')
%%here I store the first - fifth time
%%into vector varibles "time1" -"time5"
name = ['time',num2str(j)];
eval([name,'= t(end);']);
t = [];
z = [];
end
hold off;
1 Comment
Answers (0)
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!