functions with obj as input not work

4 views (last 30 days)
Jherson Castaño
Jherson Castaño on 9 Aug 2015
Edited: Cedric on 10 Aug 2015
this is my class
classdef ServoSys
%UNTITLED2 Summary of this class goes here
% Detailed explanation goes here
properties
A=[0]
B=[0]
C=[0]
D=[0]
E=[0]
e
ts
end
methods
%__________________________________________
function [Ac,Bc,Cc,Dc]=CanonicaC(obj)
[numtf,dentf]=ss2tf(obj.A,obj.B,obj.C,obj.D);
Tf1=tf(numtf,dentf)
Ac=[zeros(length(dentf)-1)]
d=0;
for c=1:1:length(dentf)-1
for f=1:1:length(dentf)-1
if c==f-1
Ac(c,f)=1;
end
if c==length(dentf)-1
Ac(c,f)=dentf(length(dentf)-d)
d=d+1
end
end
end
end
%_______________________________
function [K] = MatrizW(obj)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
Sc=[obj.B obj.A*obj.B];
Qo=[obj.C;obj.C*obj.A];
if det(Sc)==0
disp('No controlable')
else
disp('Controlable')
end
if(det(Qo)==0)
disp('No Observable')
else
disp('Observable')
end
[numtf1,dentf1]=ss2tf(obj.A,obj.B,obj.C,obj.D);
Tf1=tf(numtf1,dentf1);
Wn=4/obj.e*obj.ts;
Bds=[1 2*obj.e*Wn Wn^2]
%Matriz de peso
p=1;
dentf1
for c=1:1:length(dentf1)-1
for f=1:1:length(dentf1)-1
fprintf(1,'ingrese el coef de la fila %i',c)
fprintf(1,' y columna %i',f)
W(c,f)=input('=');
end
end
%length(dentf1)
T=Sc*W
for a=1:1:length(dentf1)-1
K(a)=Bds(a+1)-dentf1(a+1)
end
K=K*T
end
%-------------------------------------
%________________________________
end
end
when i run it the method CanonicaC(MR) (where MR is an object of the class),displayed this
Undefined function 'CanonicaC' for input arguments of type 'ServoSys'.
srry for my english
  8 Comments
per isakson
per isakson on 9 Aug 2015
Cedric, I think you are right. However, I have failed to demonstrate it in a reproducible way, which is needed to report the "issue(s)".
Cedric
Cedric on 9 Aug 2015
Edited: Cedric on 10 Aug 2015
Hi Per, I report the issue a good half of the times using the crash report, but it is generally impossible to provide a description of what specifically lead to the crash. The typical situation is that I have used the debugger in objects that involve overloads of SUBASGn/SUBSREF, and/or accessors of some sort. Then, sometimes minutes later when I am doing something else (e.g. answering a forum question), I observe an erratic behavior (often related to variables/memory, e.g. undefined variable that I had just defined, or undefined argument in a function call that I had defined), I press on ctrl-s for saving what I am doing, and it crashes at this moment (it saves well though).
Somehow it reminds me the delayed segmentation fault situation when I was programming in C in the 90's, before I started using tools like Electric Fence.

Sign in to comment.

Answers (2)

Steven Lord
Steven Lord on 10 Aug 2015
Did you construct the object and then modify the class to add the method definition? In release R2014b we improved the object workflow by eliminating the need for you to clear the class or previous instances when you modify the definition while instances exist (see the Language and Programming section of the Release Notes for MATLAB release R2014b) but if you're using an earlier release you would need to clear the class for the new method to be recognized.

Walter Roberson
Walter Roberson on 9 Aug 2015
Your method is named CanonicaC but you are trying to invoke CanoicaC which is missing the second 'n'
  1 Comment
Jherson Castaño
Jherson Castaño on 9 Aug 2015
Thanks, but that was a mistake on my writing
the problem persists
>> CanonicaC(MR)
Undefined function 'CanonicaC' for input arguments of type 'ServoSys'.

Sign in to comment.

Categories

Find more on Software Development Tools in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!