Error writing to text file
이전 댓글 표시
Below is the code I am having issues with. The values for t and Q that are being writing onto the text file are wrong and I am not sure how to fix this.
fid= fopen('RCSimulation.txt','w');
fprintf(fid, '%% Time \t Q \t V \t i \n');
fprintf(fid, '%% (s) \t (C) \t (V) \t (Ohm) \n');
fprintf(fid, '%% ==== \t ==== \t ==== \t ==== \n');
for n=1:N
t(n+1)=t(n)+Dt; % Updates time vector
Q(n+1)=Q(n)+Dt*Qdot(t(n),Q(n)); % Calls the function f(t,Q) = Qdot
fprintf(fid,' %4.1f \t %6.1f \n', t, Q);
end
fclose(fid);
답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Text Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!