Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

The first letter of the string value was not written

2 visualizzazioni (ultimi 30 giorni)
Std1
Std1 il 12 Apr 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
Hi I wrote a code which works but I got a problem about displaying the string values that I enters
Here is the code
n=input('Please enter the number of std');
for i=1:n
names=input('Enter your name: ' , 's');
name_lists{i}=names;
fprintf('Please enter %s grades \n',name_lists{i});
grades(i)=input('')
end
fprintf( ' %s got %d points from the final exam \n', name_lists{:},grades(i));
When I run the code and After entered all string and integer values, command windows does not show the first letter of the string variables that I entered.
Help me about the problem

Risposte (1)

Thiago Henrique Gomes Lobato
I would advise you to perform the last string into a loop, so you're sure they are going to be displayed right:
n=input('Please enter the number of std');
for i=1:n
names=input('Enter your name: ' , 's');
name_lists{i}=names;
fprintf('Please enter %s grades \n',name_lists{i});
grades(i)=input('')
end
for i=1:n
fprintf( ' %s got %d points from the final exam \n', name_lists{i},grades(i));
end
  3 Commenti
Thiago Henrique Gomes Lobato
Modificato: Thiago Henrique Gomes Lobato il 12 Apr 2020
you miss the index "i" in the name_lists cell, using ":" is wrong in this case, look closely at my answer.
Std1
Std1 il 12 Apr 2020
it did work in this time, thank you very much

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by