"Reference to non-existent field 'Tabel1'"

Hi, im new in matlab, these are my codes,
%Kosongkan Tampilan
set(handles.InputA,'string','');
set(handles.InputB,'string','');
set(handles.InputC,'string','');
set(handles.InputD,'string','');
set(handles.InputE,'string','');
set(handles.InputF,'string','');
set(handles.Inputx1,'string','');
set(handles.Inputx2,'string','');
set(handles.x1final,'string','');
set(handles.x2final,'string','');
set(handles.InputTeliti,'string','');
%Ambil Data
A=str2double(get(handles.InputA,'string'));
B=str2double(get(handles.InputB,'string'));
C=str2double(get(handles.InputC,'string'));
D=str2double(get(handles.InputD,'string'));
E=str2double(get(handles.InputE,'string'));
F=str2double(get(handles.InputF,'string'));
x01=str2double(get(handles.Inputx1,'string'));
x02=str2double(get(handles.Inputx2,'string'));
T=str2num(get(handles.InputTeliti,'string'));
%Inisialisasi Variabel
syms x x1 x2 L FL
%Program Utama
x=[x01 x02];
FX=A*x1^2+B*x2^2+C*x1*x2+D*x1+E*x2+F;
VF=[2*A*x(1)+C*x(2)+D;2*B*x(2)+C*x(1)+E];
norm=sqrt(VF(1)^2+VF(2)^2);
d=VF*-1;
xn=[x(1)+L*d(1);x(2)+L*d(2)];
FL=A*xn(1)^2+B*xn(2)^2+C*xn(1)*xn(2)+D*xn(1)+E*xn(2)+F;
Lamda=solve(diff(FL,L),0);
xn=[x(1)+Lamda*d(1);x(2)+Lamda*d(2)];
%Mengisi Tabel
set(handles.Tabel1,'data',num2cell(x(1)));
guidata(hObject, handles);
while double(norm) > double(T)
x=xn
VF=[2*A*x(1)+C*x(2)+D;2*B*x(2)+C*x(1)+E];
norm=sqrt(VF(1)^2+VF(2)^2);
d=VF*-1;
xn=[x(1)+L*d(1);x(2)+L*d(2)];
FL=A*xn(1)^2+B*xn(2)^2+C*xn(1)*xn(2)+D*xn(1)+E*xn(2)+F;
Lamda=solve(diff(FL,L)==0,L);
xn=[x(1)+Lamda*d(1);x(2)+Lamda*d(2)];
Data=[norm xn(1) xn(2) Lamda];
set(handles.Tabel,'string',Data);
guidata(hObject, handles);
end
it's a steepest descent code, and when I pushed the push button, it said: Reference to non-existent field 'Tabel1'.
Error in SDNyoman>MULAI_Callback (line 144)
set(handles.Tabel1,'data',num2cell(x(1)));
Error in gui_mainfcn (line 96)
feval(varargin{:});
Error in SDNyoman (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)SDNyoman('MULAI_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback
Thank you.

 採用された回答

Image Analyst
Image Analyst 2012 年 11 月 24 日

0 投票

Are you sure you didn't misspell it? Are you sure it's not Table1 instead of Tabel1?

11 件のコメント

nypradjna
nypradjna 2012 年 11 月 24 日
Yes I'm sure :(
Image Analyst
Image Analyst 2012 年 11 月 24 日
Then you shouldn't have accepted that answer yet - that may lead others to not open your question.
Put a breakpoint on the line where it throws the error. Type handles into the command window and see what members it lists for handles. What do you see there? If Tabel1 is not there, then that's not the name of your uitable. Double-Click on the table in GUIDE and look at the "Tag" property in Property Inspector. What is the value of the tag property?
nypradjna
nypradjna 2012 年 11 月 24 日
編集済み: nypradjna 2012 年 11 月 24 日
The tag is 'Tabel1'. What should I do? :(
Image Analyst
Image Analyst 2012 年 11 月 24 日
OK, so that's what GUIDE says. But did you set a breakpoint at line 144 and type handles into the command line? Apparently by the time it gets to that line
set(handles.Tabel1,'data',num2cell(x(1)));
Tabel1 is no longer attached to handles. Please type handles in and tell me what you see (like I requested before). Just copy and paste it back here.
nypradjna
nypradjna 2012 年 11 月 24 日
編集済み: nypradjna 2012 年 11 月 24 日
It works, now I have a problem for insert data to table. Code:
{ %Kosongkan Tampilan set(handles.InputA,'string',''); set(handles.InputB,'string',''); set(handles.InputC,'string',''); set(handles.InputD,'string',''); set(handles.InputE,'string',''); set(handles.InputF,'string',''); set(handles.Inputx1,'string',''); set(handles.Inputx2,'string',''); set(handles.x1final,'string',''); set(handles.x2final,'string',''); set(handles.InputTeliti,'string','');
%Ambil Data A=str2double(get(handles.InputA,'string')); B=str2double(get(handles.InputB,'string')); C=str2double(get(handles.InputC,'string')); D=str2double(get(handles.InputD,'string')); E=str2double(get(handles.InputE,'string')); F=str2double(get(handles.InputF,'string')); x01=str2double(get(handles.Inputx1,'string')); x02=str2double(get(handles.Inputx2,'string')); T=str2num(get(handles.InputTeliti,'string'));
%Inisialisasi Variabel syms x x1 x2 L FL
%Program Utama
x=[x01 x02]; VF=[2*A*x(1)+C*x(2)+D;2*B*x(2)+C*x(1)+E]; norm=sqrt(VF(1)^2+VF(2)^2); d=VF*-1; xn=[x(1)+L*d(1);x(2)+L*d(2)]; FL=A*xn(1)^2+B*xn(2)^2+C*xn(1)*xn(2)+D*xn(1)+E*xn(2)+F; Lamda=solve(diff(FL,L),0); xn=[x(1)+Lamda*d(1);x(2)+Lamda*d(2)];
hasil=[norm x(1) x(2) Lamda]; set(handles.Tabel1,'data',hasil); guidata(hObject, handles); while double(norm) > double(T) x=xn VF=[2*A*x(1)+C*x(2)+D;2*B*x(2)+C*x(1)+E]; norm=sqrt(VF(1)^2+VF(2)^2); d=VF*-1; xn=[x(1)+L*d(1);x(2)+L*d(2)]; FL=A*xn(1)^2+B*xn(2)^2+C*xn(1)*xn(2)+D*xn(1)+E*xn(2)+F; Lamda=solve(diff(FL,L),0); xn=[x(1)+Lamda*d(1);x(2)+Lamda*d(2)]; end
The command window said: Error using set Data must be a numeric, logical, or cell array
Error in SDNyoman>MULAI_Callback (line 145) set(handles.Tabel1,'data',hasil);
Error in gui_mainfcn (line 96) feval(varargin{:});
Error in SDNyoman (line 42) gui_mainfcn(gui_State, varargin{:});
Error in @(hObject,eventdata)SDNyoman('MULAI_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating uicontrol Callback }
does my data is a double?
Image Analyst
Image Analyst 2012 年 11 月 24 日
I don't know. It should work since I think the variable can be either a numerical array or a cell array. Try saying
hasil = rand(4,4);
and then calling set and see if that works.
nypradjna
nypradjna 2012 年 11 月 24 日
The table inserted by random numbers. Do you know how to change a variable type from double to number?
Image Analyst
Image Analyst 2012 年 11 月 24 日
OK, get rid of that hasil=rand(4,4) line, and replace it with this:
whos hasil
so we can see what hasil is and try to figure out why it's not going into the table like it is when it is a random array of numbers.
nypradjna
nypradjna 2012 年 11 月 24 日
編集済み: nypradjna 2012 年 11 月 24 日
Name Size Bytes Class Attributes
hasil 1x4 60 sym
That's the result. It means that hasil is a sym, so it should be converted to numeric before inserted to the table (?)
Image Analyst
Image Analyst 2012 年 11 月 24 日
編集済み: Image Analyst 2012 年 11 月 24 日
I don't know - I don't have that toolbox. Did you try this:
hasil = double(hasil);
If that doesn't work, then I don't know. I added the Symbolic Math Toolbox to the products tag. You should do this when you make up the question initially.
nypradjna
nypradjna 2012 年 11 月 24 日
it's work, thank you :)

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by