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

Guillaume
Guillaume 2017년 3월 21일
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
Jan 2017년 3월 21일
Please describe the issus you have. It is easier to solve a problem than to guess, what the problem ist.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

태그

질문:

2017년 3월 21일

댓글:

Jan
2017년 3월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by