필터 지우기
필터 지우기

Object oriented programming problem?

조회 수: 2 (최근 30일)
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2019년 2월 7일
편집: per isakson 2019년 2월 19일
I writing a program using object oriented programming in matlab 2016b. The program gives the following error:
Error using MyPr1.internalcode.Neural.FourDimensionData
The specified superclass 'MyPr2.ap.datashare' contains a parse error, cannot be found on MATLAB's search path,
or is shadowed by another file with the same name.
The FourDimensionData and datashare are in different folders. All are private.
The error code segment is:
classdef FourDimensionData < ...
MyPr2.ap.datashare &...
MyPr2.ap.datashare.Reconstruct &...
MyPr2.ap.datashare.restore &...
How can I solve this error?

답변 (2개)

Andrey Kiselnikov
Andrey Kiselnikov 2019년 2월 7일
편집: per isakson 2019년 2월 18일
Hi, you can check this manual https://www.ee.columbia.edu/~marios/matlab/MatlabStyle1p5.pdf . It was very useful for me, when I started oop in MATLAB. Also you should check ALL file paths in your application. I prefer to write some function like attached, that configures all file paths before execution.
function config_paths
rootDir = fileparts(which('config_paths'));
path2add{1} = rootDir;
path2add{2} = [rootDir,'folder_1'];
path2add{3} = [rootDir,'folder_2'];
% etc
end

per isakson
per isakson 2019년 2월 15일
MyPr2.ap.datashare, is that a folder, ...\+MyPr2\+ap\+datashare, or a classdef-file, ...\+MyPr2\+ap\datashare.m ?
Your code snippet indicates that in the folder, ...\+MyPr2\+ap\, you have a folder named, +datashare, together with a file named, datashare.m. Is that the case?
  댓글 수: 2
K M Ibrahim Khalilullah
K M Ibrahim Khalilullah 2019년 2월 19일
Thank you very much for your comment. \+MyPr2\+ap\+datashare are folders but Reconstruct and restore are file, that means Reconstruct.m and restore.m
per isakson
per isakson 2019년 2월 19일
편집: per isakson 2019년 2월 19일
SuperclassName must be the name of a class. IMO: That could have been more clearly stated the documentation.
classdef FourDimensionData < ...
MyPr2.ap.datashare &... % You cannot inherit from a folder
MyPr2.ap.datashare.Reconstruct &...
MyPr2.ap.datashare.restore &...

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by