Object oriented programming problem?

3 ビュー (過去 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 Center および File ExchangeSoftware Development Tools についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by