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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Import, Export, and Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!