Azzera filtri
Azzera filtri

fprintf 안에 있는 두번때 i 역할이 뭔지 궁금합니다.

3 visualizzazioni (ultimi 30 giorni)
SeungHyun Cha
SeungHyun Cha il 9 Apr 2020
for i = 0 : 255;
a = dec2bin(i);
fprintf ('%i test\n', i)
end
이런 느낌으로 코드를 간단하게 만들어 보았는데
fprintf 안에서 %i는 몇번째인지를 나타내는..? 그런거라고 알고있고 그다음에 test라는 글자가 새줄에 쓰여지도록 했는데 그 다음 , 뒤에 있는 i는 왜 넣어야하나요? 넣지않으면 에러가 뜨던데, 역할이 뭔지 궁금합니다.
혹시 추가로 fprintf 괄호 안에 있는 '' 요거가 뭘 의미하는지 알려주실 수 있으시면 도와주세요 감사합니다.

Risposta accettata

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi il 12 Apr 2020
Hello!
The "%i" in you code is the format specifier that determines the output format in which "fscanf" will write the data that is stored in the variable 'i'.
For example, in your case, "%i" refers to a Base 10 Signed Integer format, and the data in variable 'i' will be written by function 'fscanf' in that way. Similarly, "%u" represents Base 10 Unsigned Integer format, and so on.
The exhaustive list of all format specifiers used by the function "fscanf" can be found in its documentation page at this link:
Hope this helps!

Più risposte (0)

Categorie

Scopri di più su MATLAB 시작하기 in Help Center e File Exchange

Tag

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!