Creating a column vector of strings of various sizes

조회 수: 15 (최근 30일)
Gian Carpinelli
Gian Carpinelli 2018년 4월 9일
댓글: Gian Carpinelli 2018년 4월 9일
hey so as the title says, I need to create a database / 'library'. I need to save each 'book' entered by the user ( the total amount of books entered is unknown, i.e. can enter as many as they want)into a vertical vector. Ive tried using strvcat and char and other methods to add elements to an empty vector but I keep getting dimension errors. Please help
cheers

채택된 답변

KSSV
KSSV 2018년 4월 9일
books = cell(3,1) ;
books{1} = 'MATLAB';
books{2} = 'MAT';
books{3} = 'LAB';
Read about cell
  댓글 수: 3
KSSV
KSSV 2018년 4월 9일
books = cell([],1) ;
for i = 1:3
book = input('Book Name:','s') ;
books{i,1} = book ;
end
Gian Carpinelli
Gian Carpinelli 2018년 4월 9일
does this only work for 3 entries of the book though?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by