How do I create a user modified profile database?

1 view (last 30 days)
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 Comments
Geoff Hayes
Geoff Hayes on 22 Mar 2015
George - please post your code so that we can provide some guidance.
George
George on 22 Mar 2015
Edited: Geoff Hayes on 22 Mar 2015
counter = 1;
%prompt for new or old user
userinput = input('\nAre you a new user (Y/N): ','s');
while userinput ~= 'y' && userinput ~= 'n'
userinput = input('\nError! please enter (Y/N): ','s');
index = counter + 1;
end
if userinput == 'y'
user_name = input('\n\nplease enter name: ','s');
profile_names{index} = user_name;
else userinput == 'n'
old_profile = input('Please enter name of profile: ','s');
end
In the end I might use a GUI to make it a little more easy on the eyes, but would like to know how to code it first. thank you.

Sign in to comment.

Answers (1)

Geoff Hayes
Geoff Hayes on 22 Mar 2015
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).
  1 Comment
George
George on 25 Mar 2015
thanks for your help guys. I believe i have figured how to add a new user profile to my excel sheet.
now my issue is:
I want to add a vector [x,y,z]'from 'inputdlg box' to one cell in my excel which specific to one profile name(have the code written to find the position already). once this cell is populated, i want to create a code for the user to view or edit that vector in the future.
The second is similar to the first issue. similar since i want to add more vectors to other cells in excel for that individual (probably same type of code as above). code will be different because these other cells will grow with use of program. Meaning I would like for theses other cells to hold alot of other vectors (differentiable but date I hope) which i hope to be able to access later to plot and or graph.
Thank you

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!