How do I create a user modified profile database?
1 次查看(过去 30 天)
显示 更早的评论
How do I create a user (profile name) updated database that updates everytime a new name is added, and will also allow the user to erase their profile if needed? This information will be used to title and store excel data and personal data.
4 个评论
回答(1 个)
Geoff Hayes
2015-3-22
George - you should check out the link debugging in MATLAB as it will provide some very useful tips on how to debug your code.
If I try to run the above as a new user, then once I type in my name, the following error message appears
Undefined function or variable "index".
because of the line of code
profile_names{index} = user_name;
The local variable index is only ever assigned if the user does not enter Y or N and the body of the while loop is invoked. (As an aside when comparing string data, use strcmpi or strcmp instead of the equality or inequality operators.) It isn't clear to me why index is assigned in this loop - it seems very unnecessary. Instead, just use counter as
if strcmpi(userinput,'y')
user_name = input('\n\nplease enter name: ','s');
profile_names{counter} = user_name;
counter = counter + 1;
else
old_profile = input('Please enter name of profile: ','s');
end
Now try doing something similar for the else body in the above code (which presumably is meant to remove the user account).
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!