How can I save the output in a loop to an external text file?
이전 댓글 표시
In my loop, I'm trying to save the outputted values of eccentricity to a text file so that I can use this to plot the answers for my results but it's just not working and I have no clue where I'm going wrong.
I don't want to save every value that comes out because there'll be a lot, I just want to save 1 value for every 100 so I've set up a for loop but I'm not very experienced with MATLAB so I think it's ended up a bit of a mess. Any help would be incredibly appreciated
The loop:
D=dot(P(2,:), V(2,:))
e1=norm(V(2,:));
e1=e1^2
mu=G*M(1)
e2=e1/mu
r1=norm(P(2,:))
e3=e2/r1
e4=e3*P(2,:)
e5=D/mu
e6=e5*V(2,:)
e=e4-e6
emag=norm(e)
emag=emag/1.0e+10
%t = t + steps*delta;
steps = 100;
delta = 0.5;
update_plot(P,H,t)
for i = 1: n
m = 0;
m = m + 1;
if m == 100
C{i} = emag;
C2{i} = t;
E(i,1) = emag;
E(i,2) = t;
dlmwrite('local filename.txt',emag,'-append', '\t')
dlmwrite('local filename.txt',t,'-append', '\t')
%m = 0;
t = t + steps*delta;
end
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Data Import and Export에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!