I'm trying to create an array of struct and prompt the user to fill its fields individually.
book =struct('name',{''}, 'author',{''}, 'pubdate',{''}, 'price',{})
nmbr=input('enter number of books');
books = repmat(book, nmbr, 1);
for i=1:nmbr
books(i).name = input(sprintf('enter name of book #(%d)',i), 's')
books(i).author = input(sprintf('entre author of book #(%d)',i), 's')
books(i).pubdate = input(sprintf('enter publication date of book #(%d)',i), 's')
books(i).price = input(sprintf('enter price of book #(%d)',i))
end
However, I'm missing something as I keep getting this error:
??? Attempt to call constructor struct with incorrect letter case.
Error in ==> struct at 1
book =struct('name',{''}, 'author',{''}, 'pubdate',{''}, 'price',{})
I tried declrng the struct differently
book =struct('name','', 'author','', 'pubdate','', 'price','')
But I keep getting the same error for some reason.
Any ideas on what I'm doing wrong would be appreciated. Thank you.