How to create a session for images using matlab 2013a
1 回表示 (過去 30 日間)
古いコメントを表示
Sir, I need a help regarding how to store images using matlab 2013a. In my page, I'm going to select images and I cropped that images and I stored those images in a folder for one user. In my case , I can crop images and successfully store images in a folder but when multiple users login and crop their images and stored it. Please help me about how can store images for different users while logging in.
2 件のコメント
Adam
2017 年 3 月 16 日
Don't your users just select a folder to save to as with most windows applications that allow saving?
回答 (2 件)
John D'Errico
2017 年 3 月 16 日
This just seems to be a question of good programming design, best done in advance. Think about the needs for your code. If one such need is that each user has their own special place, then when they access the tool, you have them indicate where that will be. If they need to "login" to use this gui, then that tells you who the user is.
Probably easiest is to just define a database of users, which you could store in a .mat file. It would include any such information about where they wanted files stored. Then just update that file as necessary.
Or, you could probably store any user specific information using the preferences tools in MATLAB.
help setpref
help getpref
Walter Roberson
2017 年 3 月 17 日
function name = whoami
if ispc()
name = getenv('USERNAME');
else
name = getenv('USER') ;
end
You can now use the returned string as the folder name within some constant project folder. Watch out as you will want new users to be able to create the appropriate folder at need, which requires that everyone has write access to the project folder. But then that is a risk because people could potentially remove other people's work.
More common would be to save the files in a directory owned by the user. On pc you can use the Windows environment variables to figure out an appropriate location; on osx or Linux you can use the HOME environment variable.
Or you could use uigetdir() to allow the user to indicate which directory they want to use.
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!