Hi I got the code but I'm stuck cause it says my morse doesnt exist. Below is the coding for the morse code on GUI. The problem right now is I cant diplay the result .
I think my code might be wrong. Really need help.
function varargout = morse(varargin)% MORSE MATLAB code for morse.fig
% MORSE, by itself, creates a new MORSE or raises the existing
% singleton*.
%
% H = MORSE returns the handle to a new MORSE or the handle to
% the existing singleton*.
%% MORSE('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in MORSE.M with the given input arguments.
%% MORSE('Property','Value',...) creates a new MORSE or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before morse_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to morse_OpeningFcn via varargin.
%% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help morse
% Last Modified by GUIDE v2.5 07-Apr-2020 14:41:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;gui_State = struct('gui_Name', mfilename, ... 'gui_Singleton', gui_Singleton, ... 'gui_OpeningFcn', @morse_OpeningFcn, ... 'gui_OutputFcn', @morse_OutputFcn, ... 'gui_LayoutFcn', [] , ... 'gui_Callback', []);if nargin && ischar(varargin{1}) gui_State.gui_Callback = str2func(varargin{1});endif nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});else gui_mainfcn(gui_State, varargin{:});end% End initialization code - DO NOT EDIT
% --- Executes just before morse is made visible.
function morse_OpeningFcn(hObject, eventdata, handles, varargin)% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to morse (see VARARGIN)
% Choose default command line output for morse
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes morse wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = morse_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure
varargout{1} = handles.output;function L_edit_Callback(hObject, eventdata, handles)% hObject handle to L_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of L_edit as text
% str2double(get(hObject,'String')) returns contents of L_edit as a double
letter=get(hObject,'string');Letter_num=str2double(letter);handles.Letter=letter;guidata(hObject,handles)% --- Executes during object creation, after setting all properties.
function L_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to L_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end% --- Executes on button press in PB_M.
function PB_M_Callback(hObject, eventdata, handles)% hObject handle to PB_M (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)Letter=handles.Lettermorse={'.----','..---','...--','....-','.....','-....','--...','---..','----.','-----','.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','/'}; NumberOrLetter={'1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '};for i=1:length(Letter); [~, index] = ismember(Letter(i), NumberOrLetter); if index > 0 set(handle.Morse,sprintf,'string'); end end% --- Executes on button press in PB_L.
function PB_L_Callback(hObject, eventdata, handles)% hObject handle to PB_L (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)Morse=handles.Morsemorse={'.----','..---','...--','....-','.....','-....','--...','---..','----.','-----','.-','-...','-.-.','-..','.','..-.','--.','....','..','.---','-.-','.-..','--','-.','---','.--.','--.-','.-.','...','-','..-','...-','.--','-..-','-.--','--..','/'}; NumberOrLetter={'1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' '};for i=1:length(Morse); [~, index] = ismember(morse(i),NumberOrLetter); if index > 0 set(handle.Morse,sprintf,'string'); end endfunction M_edit_Callback(hObject, eventdata, handles)% hObject handle to M_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB% handles structure with handles and user data (see GUIDATA)% Hints: get(hObject,'String') returns contents of M_edit as text
% str2double(get(hObject,'String')) returns contents of M_edit as a double
Morse=get(hObject,'string');Morse_num=str2double(Morse);handles.Morse=Morse;guidata(hObject,handles)% --- Executes during object creation, after setting all properties.function M_edit_CreateFcn(hObject, eventdata, handles)% hObject handle to M_edit (see GCBO)% eventdata reserved - to be defined in a future version of MATLAB% handles empty - handles not created until after all CreateFcns called% Hint: edit controls usually have a white background on Windows.% See ISPC and COMPUTER.if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) set(hObject,'BackgroundColor','white');end
Best Answer