MATLAB: If i want to input just primes number in the GUI codes

guiMATLAB

I have GUI codes
function key_Callback(hObject, eventdata, handles)
% hObject handle to key (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
p=get(handles.p,'string');
p=str2num(p);
q=get(handles.q,'string');
q=str2num(q);
[D,E,N]=generatekey(p,q);
handles.D = D;
handles.E = E;
handles.N = N;
set(handles.d, 'String',D);
set(handles.e, 'String',E);
set(handles.n, 'String',N);
if I want the values p and q to be prime numbers, so if the value p and q are not prime numbers a notification will appear that the value p and q are not prime numbers and must repeat the input. pls help me this in GUI matlab.

Best Answer

if ~(isprime(p) && isprime(q))
uiwait(msgbox('Primes only!'))
return
end