필터 지우기
필터 지우기

unable to detect a class file to instantiate object

조회 수: 5 (최근 30일)
Udaykaran Madaan
Udaykaran Madaan 2023년 5월 26일
답변: Swaraj 2023년 5월 29일
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

답변 (1개)

Swaraj
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.
  1. To make sure that MATLAB is loading the class correctly you can run the command in the command window: clear classes
  2. Note that LLSPP needs to be on your MATLAB search path, or the full path to LLSPP.trial should be specified.
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!!.

카테고리

Help CenterFile Exchange에서 Software Development Tools에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by