フィルターのクリア

GUI edit box with the desktop path MAC

3 ビュー (過去 30 日間)
Erdem Uguz
Erdem Uguz 2016 年 1 月 12 日
コメント済み: Kamuran 2016 年 1 月 13 日
Hello, I am trying to set the box with the desktop path in Mac I get the user name using
if true
user_name = java.lang.System.getProperty('user.name');
set(handles.edit1,'String',['/Users/',user_name,'/Desktop']);
end
This is working in windows pc but not in mac. I receive The following error occurred converting from char to opaque: Undefined function 'opaque' for input arguments of type 'char'.
Any idea why it is not working?

採用された回答

Geoff Hayes
Geoff Hayes 2016 年 1 月 13 日
Erdem - look closely at the data type for user_name
user_name = java.lang.System.getProperty('user.name');
class(user_name)
ans =
java.lang.String
user_name is not a MATLAB character (char) array but is a string object instead. You need to convert this to a MATLAB character array using char as
user_name = char(java.lang.System.getProperty('user.name'));
set(handles.edit1,'String',['/Users/',user_name,'/Desktop']);
Try the above and see what happens!
  1 件のコメント
Kamuran
Kamuran 2016 年 1 月 13 日
Thanks . you are right. I will try that.

サインインしてコメントする。

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 1 月 13 日
Why are you not using
set(handles.edit1, 'String' fullfile(getenv('HOME'), 'Desktop'))
  1 件のコメント
Kamuran
Kamuran 2016 年 1 月 13 日
simply because I didn't know that :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by