fprintf not printing to command window when asking for input.
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello. I am working on a Jukebox to play a song that corrisponds with set number (this part is not the issue I am just trying to provide some context).
When the code is run I would like the Opening menu to appear in the command window so the user can see the song choices before being prompted to enter an input. The problem is that when I run the code it does not print any of my text and just waits for an input. I think it has something to do with the fact that other than declaring some variables, there is nothing happening before the first fprintf. I am not getting any error or warning messages on my end.
Is this a quirk of using the online version? I am using the online verison of MATlab because I am having techinal issues with installing the desktop version.
(This is not all of my code, I chose to only share what is relevent to my issue)
clear
clc
close all
%% Declarations
rate = 32768; % sampling rate
songs = 1:9;
octave = 0;
speed = 0;
% Opening menu. Give list of options
fprintf(['Welcome to Jukebox.\n-------- SONG MENU --------\n 1 |'...
' Bohemian Rhapsody \n 2 | ' ...
'Dies Irae \n 3 | Entry Into Valhalla \n 4 | Fur Elise \n 5 | ' ...
'Game of Thrones Theme \n 6 | He''s a Pirate \n 7 | Megalovania ' ...
'Long \n 8 | Paint it Black \n'])
% Prompt user for selection, and check validity of choice
songNum = input(['Enter the number of the song you wish to play --> \n']);
while songNum < 0 || songNum > 9 || mod(songNum,1) ~= 0
songNum = input('Try again --> ');
end
0 commentaires
Réponses (2)
Star Strider
le 17 Sep 2024
When I run your input line, it prints this to my Command Window:
Enter the number of the song you wish to play -->
and then waits for an input. It works for me (R2024b).
1 commentaire
Walter Roberson
le 17 Sep 2024
Is it possible that you are using LiveScript ? When you use LiveSript, the output of fprintf() goes to the script window rather than to the command window.
0 commentaires
Voir également
Catégories
En savoir plus sur Desktop dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!