I need to write a script that will prompt the user for four course numbers. Each will be a string of length 5 of the form ‘CS101’. These strings are to be stored in a character matrix.
조회 수: 3 (최근 30일)
이전 댓글 표시
Don't really know how to store as a character matrix
댓글 수: 0
답변 (1개)
Chris C
2014년 3월 17일
This can be done in a structure setting as well which would probably make storage and recall easier, but to answer your question you could just use the below:
CourseNums = cell(1,4);
for i =1:4
display('Please enter your course numbers: ');
CourseNums{i} = input(sprintf('Course %d: ',i),'s');
end
CourseNums
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!