how to access variables from one function to another function?

I have created GUI, I am trying to acess variable featureVector from one function to another function.
Kindly help me.
Here is my code of functions:
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
featureVector = extractHOGFeatures(Img);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
Classifier=trainedClassifier;
Label=Classifier.predictFcn(featureVector);

 채택된 답변

Guillaume
Guillaume 2018년 12월 22일
The simplest is to store your feature vector in handles.
% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
handles.featureVector = extractHOGFeatures(Img); %store feature vector in handles
guidata(hObject, handles); %and save handles
end
function pushbutton5_Callback(hObject, eventdata, handles)
Classifier=trainedClassifier;
Label=Classifier.predictFcn(handles.featureVector); %get feature vector from handles
...
end

댓글 수: 1

How to do this same thing in the Appdesigner? I have a similar issue: in a first function I have a vector "I" (given by a Gaussian function), and I want to use/recall that vector in another function. It looks like simple
app.I = I
is not working.

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Histograms에 대해 자세히 알아보기

질문:

2018년 12월 22일

댓글:

2021년 1월 17일

Community Treasure Hunt

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

Start Hunting!

Translated by