Pop-up Menu Issue

조회 수: 1 (최근 30일)
Zeeshan Abbas
Zeeshan Abbas 2019년 7월 26일
댓글: Zeeshan Abbas 2019년 7월 27일
I have a pop-up menu having two options:
  1. Get message from user
  2. Upload message from file
The 2nd option is working fine but when I choose 1st option it's giving error:
Reference to non-existent field 'message'.
Error in mainmain>Embed_Callback (line 201)
message=handles.message;
The pop-up buttons function is as below:
function popupmenu1_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns popupmenu1 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu1
Contents =cellstr(get(hObject,'String'));
pop_choice=Contents(get(hObject,'Value'));
pop_choice;
if (strcmp(pop_choice,'Enter Message'))
message=get(handles.EnterMessage,'string');
handles.message=message;
elseif (strcmp(pop_choice,'Upload Message'))
[file,Path]=uigetfile('*.txt','Select file to read message,'.')
message = fileread(fullfile(Path,file));
handles.message=message;
end
guidata(hObject,handles)
  댓글 수: 11
Rik
Rik 2019년 7월 26일
The string property contains a char array, not a string. This confusion was created when Mathworks introduced strings as a new data type, but (luckily) didn't rename properties or change their data types. That means both paths in your code should lead to char arrays.
So now the question is: have you made sure the message field contains a non-empty char array? And what do you mean with decoding?
Zeeshan Abbas
Zeeshan Abbas 2019년 7월 27일
Oh thanks for the clarification. Actually I am working on steganography so when I am embedding message using the uploading file I can extract the message properly but when I am getting input from user and then extracting the message it’s giving garbage value. Might be the field is not getting the user input. Making clear that both is working fine in editor and creating issue on GUI only.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by