Error writing to text file
Afficher commentaires plus anciens
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);
2 commentaires
Guillaume
le 21 Mar 2017
So, what is being written and what should be written?
What is the contents of t and Q at the end of the loop? What is in written in the file?
Jan
le 21 Mar 2017
Please describe the issus you have. It is easier to solve a problem than to guess, what the problem ist.
Réponses (0)
Catégories
En savoir plus sur Text Files dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!