Error using fprintf Invalid file identifier. Use fopen to generate a valid file indetifier
Afficher commentaires plus anciens
Hello all,
I'm getting the following error message when using fprintf to print a concatenated string to the console output:
Error using fprintf
Invalid file identifier. Use fopen to generate a valid file identifier.
Error in print_Test2_Stats (line 11)
s2 = "TOTAL FRAMES SENT = " + Total_Frames_t2_64Mb + "\n"; fprintf(s2);
Here is the extract from my code:
fprintf('\n');
fprintf('======================= Test 2 Round Robin Summary ======================\n');
fprintf('BOND TYPE = HOMOGENEOUS 11ac\n');
fprintf('TEST TYPE = LHS (n = 1)\n');
fprintf('SCHEDULING = ROUND ROBIN\n');
fprintf('SELECTION = STATIC\n');
fprintf('HOLD VALUE = N/A\n');
s1 = "TOTAL TIME TAKEN (us) = " + Total_Time_t2_64Mb + "\n"; fprintf(s1);
s2 = "TOTAL FRAMES SENT = " + Total_Frames_t2_64Mb + "\n"; fprintf(s2);
s3 = "TOTAL BITS SENT = " + Total_Bits_t2_64Mb + "\n"; fprintf(s3);
s4 = "TOTAL BYTES SENT = " + Total_Bytes_t2_64Mb + "\n"; fprintf(s4);
s5 = "TOTAL KILOBYTES SENT = " + Total_KBytes_t2_64Mb + "\n"; fprintf(s5);
s6 = "TOTAL MEGABYTES SENT = " + Total_MBytes_t2_64Mb + "\n"; fprintf(s6);
s7 = "MEAN CHAN THROUGHPUT = " + Ch_Bond_Tput_Mean_t2_64Mb + "\n"; fprintf(s7);
I have another similar function called print_Test1_Stats with exactly the same code and this is working fine:
fprintf('\n');
fprintf('======================= Test 1 Round Robin Summary ======================\n');
fprintf('BOND TYPE = HETEROGENEOUS 11ac-11ah\n');
fprintf('TEST TYPE = BALANCED\n');
fprintf('SCHEDULING = ROUND ROBIN\n');
fprintf('SELECTION = STATIC\n');
fprintf('HOLD VALUE = N/A\n');
s1 = "TOTAL TIME TAKEN (us) = " + Total_Time_t1_64Mb + "\n"; fprintf(s1);
s2 = "TOTAL FRAMES SENT = " + Total_Frames_t1_64Mb + "\n"; fprintf(s2);
s3 = "TOTAL BITS SENT = " + Total_Bits_t1_64Mb + "\n"; fprintf(s3);
s4 = "TOTAL BYTES SENT = " + Total_Bytes_t1_64Mb + "\n"; fprintf(s4);
s5 = "TOTAL KILOBYTES SENT = " + Total_KBytes_t1_64Mb + "\n"; fprintf(s5);
s6 = "TOTAL MEGABYTES SENT = " + Total_MBytes_t1_64Mb + "\n"; fprintf(s6);
s7 = "MEAN CHAN THROUGHPUT = " + Ch_Bond_Tput_Mean_t1_64Mb + "\n"; fprintf(s7);
This error started appearing out of the blue and has worked fine before. Could this be a bug or is it a programming fault?
1 commentaire
Adam Danz
le 30 Juil 2020
What's the value of S2?
s2 = "TOTAL FRAMES SENT = " + Total_Frames_t2_64Mb + "\n"
Réponse acceptée
Plus de réponses (2)
Michael Dilmore
le 30 Juil 2020
0 votes
Michael Dilmore
le 30 Juil 2020
0 votes
1 commentaire
Adam Danz
le 30 Juil 2020
Glad I could help you pinpoint the root of the problem.
Catégories
En savoir plus sur Whos 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!