Class Overriding and Package Namespacing?

조회 수: 6 (최근 30일)
Jason Mortimer
Jason Mortimer 2015년 2월 24일
편집: per isakson 2015년 2월 24일
I have two areas involving package namespacing which are frustrating me. The first of which being my class definition. The classes are both in different packages, so to inherit from a class in another packge I did:
classdef inputIniReader < AnalysisUtil.DataIO.File.iniReader
But I cannot 'import' before hand in order to get this:
import AnalysisUtil.DataIO.File.iniReader;
classdef inputIniReader < iniReader
Is there any way to achieve the shortened name?
Another issue is where I am overriding a method from a super class:
% Imports
import AnalysisUtil.DataIO.File.iniReader;
% Read the raw data.
data = obj.read@iniReader(filePath);
This code does not work because:
'iniReader' is not a valid base class.
I also tried:
% Imports
import AnalysisUtil.DataIO.File.*;
And it still didn't work. Do I really need to fully qualify the namespace just to call the super method from within an overriding function like this?:
% Read the raw data.
data = obj.read@AnalysisUtil.DataIO.File.iniReader(filePath);
Because this is the only solution that seems to work.

채택된 답변

per isakson
per isakson 2015년 2월 24일
편집: per isakson 2015년 2월 24일
  • "Is there any way to achieve the shortened name?" &nbsp No.
  • "And it still didn't work" &nbsp Neither when I try with R2013b. I thought it would. Cannot find it described in the documentation.
  • "fully qualify the namespace" &nbsp My code is littered with names of packages.
This is a topic for What frustrates you about MATLAB? There the audience is larger.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by