Simple question regarding feld width in matlab
이전 댓글 표시
If saw a question in the internet which asks to write a segment code that prompt the user for a charcter and will print it twice; once left-justified in a field width of 5, and again right-justified in a field width of 3:
Here is my working:
ask=input('Enter a charcter: ','s');
fprintf('First time: %c\n',ask);
fprintf('First time:%c \n',ask);
댓글 수: 3
Sultan Al-Hammadi
2018년 6월 23일
편집: Walter Roberson
2018년 6월 23일
Walter Roberson
2018년 6월 23일
편집: Walter Roberson
2018년 6월 23일
Neither one are correct. Your first one does not left justify and the right one does not print the character.
답변 (1개)
Walter Roberson
2018년 6월 23일
0 개 추천
Use %-5c and %3c format items
카테고리
도움말 센터 및 File Exchange에서 Standard File Formats에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!