How do I create a user modified profile database?

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

George - how is this a MATLAB question? Are you creating a MATLAB GUI that will allow a user to create a profile that you wish to save to some database using SQL or is it much simpler and you just want to save this information to file? Please provide more details.
yes this is for MATLAB. It does not have to be a GUI. I am just trying to write code to allow the user to create a new profile (excel data sheets) or delete a old profile, or select an old profile. I have tried using a loop but the information is just replacing the old input, not adding to the database.
Thanks in advance George
George - please post your code so that we can provide some guidance.
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)

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

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.

Categories

Asked:

on 21 Mar 2015

Commented:

on 25 Mar 2015

Community Treasure Hunt

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

Start Hunting!