Borrar filtros
Borrar filtros

how to call variable from another function in matlab - Reference to non-existent field 'nameoffile'.

2 visualizaciones (últimos 30 días)
Hello,
I need use veriable from another function,
  • Undefined function or variable 'nameoffile'.*
i tried fix it, but i didnt.
function Imageupdate_Callback(hObject, eventdata, handles)
% hObject handle to Imageupdate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName, Path] = uigetfile('*.bmp; *.png; *.jpg', 'Resim seçin' );
nameoffile = fullfile(Path,FileName);
imshow(nameoffile);
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
Pname = get(handles.PersonName,'String');
PSurname = get(handles.PersonSurname,'String');
Bday = get(handles.PersonBDay,'String');
Bplace = get(handles.PersonBP,'String');
Psex=get(handles.PGSex, 'SelectedObject');
Psex=get(Psex,'Tag');
PPhone = get(handles.PPhone,'String');
Padd = get(handles.Padd,'String');
% if isempty(Pname)
% fprintf('Error: Enter Text first\n');
% else
% Write code for computation you want to do
% end
connectface = database('facerecognition','root','');
PersonalID = exec(connectface,'Select max(PID) from person');
PersonalID = fetch(PersonalID)
PersonalID = PersonalID.data
close(connectface);
addaperson(Pname,PSurname,Bday,Bplace,Psex,PPhone,Padd);
addaface(nameoffile,PersonalID);

Respuesta aceptada

Walter Roberson
Walter Roberson el 11 de Sept. de 2015
  2 comentarios
Gkhn A
Gkhn A el 12 de Sept. de 2015
Thank you for your answer. Yeah I looked it , but i didn't make. Can you edit my code?
Geoff Hayes
Geoff Hayes el 12 de Sept. de 2015
Gkhn - in your callback that reads the image, save it to the handles structure as
function Imageupdate_Callback(hObject, eventdata, handles)
[FileName, Path] = uigetfile('*.bmp; *.png; *.jpg', 'Resim seçin' );
nameoffile = fullfile(Path,FileName);
imshow(nameoffile);
handles.nameoffile = nameoffile;
guidata(hObject, handles);
Now, nameoffile is a field within the handles structure that other callbacks can access. So in your other callback, do the following
function pushbutton2_Callback(hObject, eventdata, handles)
% other stuff
addaperson(Pname,PSurname,Bday,Bplace,Psex,PPhone,Padd);
if isfield(handles,'nameoffile')
addaface(handles.nameoffile,PersonalID);
end

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by