フィルターのクリア

set uitable in a function matlab

2 ビュー (過去 30 日間)
Yusran Said
Yusran Said 2017 年 10 月 29 日
コメント済み: Yusran Said 2017 年 10 月 30 日
i have function call fungsiocr, this is my code to call that function
kandidatpelat=struct(a(11,:),value{1},a(12,:),value{2},a(13,:),value{3},a(14,:),value{4});
[ykandidatpelatf11 xkandidatpelatf11]=size(kandidatpelat.f11);
[ykandidatpelatf12 xkandidatpelatf12]=size(kandidatpelat.f12);
if((ykandidatpelatf11>0) && (xkandidatpelatf11>0))
Fungsiocr(kandidatpelat.f11,handles.mpengujiana1);
end
if((ykandidatpelatf12>0) && (xkandidatpelatf12>0))
Fungsiocr(kandidatpelat.f12,handles.mpengujiana2);
end
and my code in a function
function colorImage=Fungsiocr(datacitrargb,dataaxes)
colorImage=datacitrargb;
results = ocr(colorImage,'CharacterSet','0123456789QWERTYUIOPLKJHGFDSAZXCVBNM');
final_output=[];
final_output=[final_output deblank(results.Text)];
axes(dataaxes);
imshow(Img_Awal);
title(strcat('Detected Text : ',final_output));
i want to set database in that function with this code
%%Database
data_plat = load('Data_Plat.mat');
Database_All = data_plat.Database_All;
data2 = table2cell(Database_All(strcmpi(Database_All.Plat, final_output), ...
{'Plat', 'Nama', 'Jurusan', 'Status'}));
data2 = [get(handles.uitable1, 'Data'); data2];
data2(all(cellfun('isempty',data2),2),:) = [];
[~,idx]=unique(cell2table(data2),'rows');
unique_data2 = data2(idx,:);
set(handles.uitable1, 'Data', unique_data2);
the question is, how can i do that?, that always get error Undefined variable "handles" or class "handles.uitable1", because i want put that code in a function, any suggestion what can i do to solve my problem?? i want to procces every data to always set up in table when i call that function

採用された回答

Image Analyst
Image Analyst 2017 年 10 月 30 日
編集済み: Image Analyst 2017 年 10 月 30 日
If you're using GUIDE, then all callbacks (what gets executed when you interact with some control on the GUI) will automatically have access to handles. If you don't have it, then you must have deleted it from the input argument list, or called "clear" in the callback function itself.
OTHER (non-callback) functions will not automatically have access to the handles structure variable. To get them to have access, you have to pass in handles to them when you call the functions. Of course the calling function must also have access to handles, such as the caller being a callback function or a custom user-written function that has had handles passed into it. For example, you have a push button callback function call a function Fungsiocr() which is your last chunk of code:
[colorImage, handles] = Fungsiocr(handles, datacitrargb, dataaxes)
Make sure you change the function definition of Fungsiocr() to include handles as the first input argument.
You don't need to pass handles back out if you call guidata() inside Fungsiocr() since that will update handles so that other, later functions will see the changes you made. Otherwise, if you don't call guidata() in Fungsiocr(), then pass handles back out and some other function will eventually call it.
  1 件のコメント
Yusran Said
Yusran Said 2017 年 10 月 30 日
thanks a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMigrate GUIDE Apps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by