- To make sure that MATLAB is loading the class correctly you can run the command in the command window: clear classes
- Note that LLSPP needs to be on your MATLAB search path, or the full path to LLSPP.trial should be specified.
unable to detect a class file to instantiate object
10 次查看(过去 30 天)
显示 更早的评论
My file structure is like this
+LLSPP
TMS_2023.m
trial.m
some other files..
in 'trial.m' I have a class definition with a constructor
I am using this in TMS_2023.m
import LLSPP.*
and later trying to instantiate the class
T1 = LLSPP.trial(input1, input2)
but I keep getting this :
Unable to resolve the name 'LLSPP.trial'.
I also tried
T1 = LLSPP.trial.trial(input1, input2)
and
T1 = trial.trial(input1, input2)
and
T1 = trial(input1, input2)
they give the same error
0 个评论
回答(1 个)
Swaraj
2023-5-29
Hi Udaykaran,
I understand that you are not able to access the constructor/class from a script written in the same package. I tried to regenerate the issue. I created the following file structure.
The content of the files are as follows:
File : trial.m
classdef trial
properties
Value;
end
methods
function obj = trial(input1,input2)
obj.Value = input1+input2;
end
end
end
File : TMS_2023.m
import LLSPP.*
LLSPP.trial(10,10);
On running the script “TMS_2023.m”, I was able to access the constructor.
The steps that you followed should work fine. Please try the following steps because of which you might face this error.
If the above steps do not help, please check if you have written the “trial” class properly. Go through the following documentation for reference.
Hope it helps!!.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Construct and Work with Object Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!