필터 지우기
필터 지우기

Cannot find 'set' method for .... class

조회 수: 15 (최근 30일)
Yves
Yves 2017년 12월 15일
댓글: Giuseppe Degan Di Dieco 2021년 10월 21일
Matlab complains about a set method that has already been defined. The error message is, when I type in the command:
set(a, 'prop1', 1)
"Error using set. Cannot find 'set' method for aSimpleValueClass class".
classdef aSimpleValueClass
properties
prop1
end
methods
function obj = set.prop1(obj, x)
obj.prop1 = x;
end
end
end
Can someone tell me why?

채택된 답변

Walter Roberson
Walter Roberson 2017년 12월 15일
You would need to have defined a method named set for that case. The set.prop1 method is called for the case where you use
a.prop1 = value
  댓글 수: 8
Yves
Yves 2017년 12월 15일
Ahh...I see. Thx, Guillaume.
Giuseppe Degan Di Dieco
Giuseppe Degan Di Dieco 2021년 10월 21일
Also, thanks by me!
Best!

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

추가 답변 (2개)

sneha pc
sneha pc 2020년 5월 3일
error- set is not comaptable with sym class. what to do
M = 0.5;
m = 0.2;
b = 0.1;
I = 0.006;
g = 9.8;
l = 0.3;
q = (M+m)*(I+m*l^2)-(m*l)^2;
syms s
Ppend=((m*l*s^2)/q)/(s^4+(b*(I+m*l^2)*s^3)/q-((M+m)*m*g*l*s^2)/q-(b*m*g*l*s)/q);
disp(Ppend);
Pcart=(((I+m*l^2)*s^2-g*m*l)/q)/(s^4+(b*(I+m*l^2)*s^3)/q-((M+m)*m*g*l*s^2)/q-(b*m*g*l*s)/q);
disp(Pcart)
sys_tf = [P_cart ; P_pend];
inputs = {'u'};
outputs = {'x'; 'phi'};
set(sys_tf,'InputName',inputs)
set(sys_tf,'OutputName',outputs)
sys_tf;

Walter Roberson
Walter Roberson 2020년 5월 3일
You created a symbolic expression that looks like a transfer function, and you are expecting that it is suddenly the transfer function datatype instead of being symbolic.
You should use the routine in this link:
https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/26553/versions/2/previews/sym2tf.m/index.html

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by